1) gcd(x,y): greatest common divisor or denominator
int gcd(int x, int y) {
if(y==0)
return x;
return gcd(y, x%y);
}
2) factorial(n)
int factorial(int n) {
if(n==0)
return 1;
return n * factorial(n-1);
}
3) lcm(x,y): lowest common multiple or multiplier
int lcm(int x, int y) {
return (x*y)/gcd(x,y);
}
int gcd(int x, int y) {
if(y==0)
return x;
return gcd(y, x%y);
}
2) factorial(n)
int factorial(int n) {
if(n==0)
return 1;
return n * factorial(n-1);
}
3) lcm(x,y): lowest common multiple or multiplier
int lcm(int x, int y) {
return (x*y)/gcd(x,y);
}
Comments
Post a Comment