MCPcopy Create free account
hub / github.com/Rustam-Z/cpp-programming / gcd

Function gcd

Lab_07/gcd.cpp:5–15  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3using namespace std;
4
5int gcd(int x, int y)
6{
7 if (x == 0 || y == 0)
8 return y, x; // will input non-zero number when even one number input in zero
9 if (x == y)
10 return x; // will return first number when both of the numbers are equal
11 if (x > y)
12 return gcd(x - y, y); // when first number is greater than second
13 if (y > x)
14 return gcd(x, y - x); // when second number is greater than first
15}
16
17int main4()
18{

Callers 1

main4Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected