Division

Feb 19, 2013 at 4:56pm
closed account (LAM21hU5)
So the user inserts two numbers. I need a code that shows the smallest number that can divide both the inserted numbers.
Feb 19, 2013 at 5:35pm
Use a for-loop that will go from 1 to the smallest of the 2 numbers and try to divide both using the numbers in the for-loop. if for-loop ends and still no divisor, then 1 is the smallest.
Feb 19, 2013 at 11:11pm
I need a code that shows the smallest number that can divide both the inserted numbers.

That's easy, cout << 1;

More often the requirement us to show the largest number which is a factor of both numbers. google "HCF algorithm".
Topic archived. No new replies allowed.