search

Home  >  Q&A  >  body text

ios - 分数相加逻辑?

1.要求求两个分数的和
2.要约分 要可以等于1 就不是要出现2/2 3/6
3.有没有公式啥的

PHP中文网PHP中文网2889 days ago477

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 17:49:35

    (๑乛◡乛๑)

    a/b + c/d = (ad + bc) / (bd)

    Appointment? Divide by the greatest common divisor

    reply
    0
  • 天蓬老师

    天蓬老师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).

    1. 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.

    2. 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.

    reply
    0
  • Cancelreply