Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

gcd and lcm in c++

long long gcd(long long int a, long long int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
long long lcm(ll int a, ll int b)
{
    return (a / gcd(a, b)) * b;
}
// there is a math formula used in this code which you can search up about,
// but you can just use it as it is.
 
PREVIOUS NEXT
Tagged: #gcd #lcm
ADD COMMENT
Topic
Name
1+5 =