Created
November 15, 2018 06:34
-
-
Save lzzy12/d271a78926116fe4b04c6fe921c31c55 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int factorial(int x) { | |
if (x == 0 || x == 1) | |
{ | |
return 1; | |
} | |
return (x * factorial(x - 1)); | |
} | |
int hcf(int x, int y) { | |
if (x == y) | |
return x; | |
int small = (x < y) ? x : y, res = 1; | |
for (int i = 1; i <= small; i++) { | |
if (x % i == 0 && y % i == 0) { | |
res = i; | |
} | |
} | |
return res; | |
} | |
int lcm(int x, int y, int z) { | |
int lcm; | |
lcm = x * y / hcf(x, y); | |
return lcm * z / hcf(lcm, z); | |
} | |
void main() { | |
int x, y, z; | |
cin >> x >> y >> z; | |
x = factorial(x); | |
y = factorial(y); | |
z = factorial(z); | |
cout << lcm(x, y, z); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment