greatest common divisor

given a fraction x/y for any x and y, does any one know a code to convert the fraction into its' simplest form?
Not off the top of my head, but two strategies do occur to me. Though actually, they're really variations of the same general idea...

I think that giving you a direct answer would defeat the point of the exercise.

Instead, you should work a few samples (with pencil and paper) and see what steps you have to take. That should allow you to identify the required algorithm. Then it's "just" a matter ot turning into C++.

By the way: the two variations of my strategy are (a) work out everything need you do first and then do the final calculation, or (b) to the calculation as you go along.

Andy

P.S. Have you already done a "finding prime numbers" exercise?
Last edited on
I suggest putting "greatest common divisor" into your google search bar and your question may be answered automatically.
Topic archived. No new replies allowed.