cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
How to find gcd using function?
How to find gcd using function?
Nov 10, 2011 at 4:38pm UTC
cozyhozy
(14)
How to write a program using function to find the greatest common division?
Does anyone has any ideas?
1
2
3
4
5
6
7
8
9
int
gcd(
int
n,
int
m) {
int
gcd = 1;
return
gcd; }
Nov 10, 2011 at 5:03pm UTC
tfityo
(174)
Read about Euclid's algorithm
http://en.wikipedia.org/wiki/Greatest_common_divisor.
And little reminder:
In C++ to find a remainder use
%
operator, and to divide use
/
operator.
Topic archived. No new replies allowed.