cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
user name:
password:
Forgot your password?
please wait
try again
cancel
forgot your password?
sign up
log in
[Legacy version]
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Division
Division
Feb 19, 2013 at 4:56pm
Feb 19, 2013 at 4:56pm UTC
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
Feb 19, 2013 at 5:35pm UTC
Smac89
(1727)
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
Feb 19, 2013 at 11:11pm UTC
Chervil
(7320)
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.