巴扎黑2017-04-17 17:49:35
(๑乛◡乛๑)
a/b + c/d = (ad + bc) / (bd)
Appointment? Divide by the greatest common divisor
天蓬老师2017-04-17 17:49:35
Let me talk about my idea, although it may not be the optimal one.
A fraction is numerator/denominator. Therefore, a fraction is represented by two integers (mixed numbers are represented by improper fractions).
The fractions are added up, which is a1/a2 + b1/b2 = (a1×b2+b1×a2)/(a2×b2). That is, the numerator of the sum is the numerator of the two fractions multiplied by the denominator of the other fraction and then added, and the denominator is the two denominators multiplied. Of course, this calculation may not be the simplest fraction, so we have to take the next step.
Reduction is to find the greatest common divisor of the numerator and denominator of the sum, and then divide them by the greatest common divisor.