How to store a fraction in reduce form

How can I store a fraction in reduce form? For example, I input fraction 2/4, and print out 1/2
You have to find the greatest common divisor of the two numbers and divide each number by it.
see http://en.wikipedia.org/wiki/Greatest_common_divisor and http://en.wikipedia.org/wiki/Binary_GCD_algorithm though that algorithm seems a little complicated...
Last edited on
My first idea was the string with which you can process. Than I used the google :)

Somebody wanted to write a class which is related your task:
http://www.daniweb.com/forums/thread38955.html#

Topic archived. No new replies allowed.