Pages

Friday, November 5, 2010

LCM of two numbers in C / C++

/* a & b are the numbers whose LCM is to be found */
int lcm(int a,int b)
{
int n;
for(n=1;;n++)
{
if(n%a == 0 && n%b == 0)
return n;
}
}

No comments: