Division

So the user inserts two numbers. I need a code that shows the smallest number that can divide both the inserted numbers.
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.
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.