Click to See Complete Forum and Search --> : LCM Function


khullaryogesh@rediffmail.com
June 6th, 2005, 03:19 AM
Hi All ,


I want to calculate the LCM of Numbers in a given vector list .

If any one knows please help me out

Yogesh

golanshahar
June 6th, 2005, 08:56 AM
i have 2 simple fuction you just have to build recursive function to work on Array

int GCD(int a, int b)
{
if ( b == 0 )
return a;
return GCD ( b,a%b);
}

int LCM(int a, int b)
{
return a*(b/GCD(a,b));

}


Cheers