How to simplify a fraction

前端 未结 3 664
旧巷少年郎
旧巷少年郎 2020-12-20 13:50

I want to simplify a fraction in my application. The fraction is like, x/y where x and y are integers. I want to simplify the fraction to its simplest form. Can anyone plea

3条回答
  •  有刺的猬
    2020-12-20 14:10

    • Compute the greatest common divisor for x and y
    • Divide both of them by the GCD

    Euclid's algorithm is an easy way to compute the GCD.

提交回复
热议问题