Saiful's World
Saturday, January 21, 2012
Standard LCM
#include<stdio.h>
int GCD(int a,int b)
{
int c;
while(b > 0)
{
c = a%b;
a = b; b = c;
}
return a;
}
int main()
{
int i,a,b,LCM;
while(scanf("%d%d",&a,&b)==2)
{
LCM = (a*b) / GCD(a,b);
printf("%d\n",LCM);
}
return 0;
}
/*
Input:
501 36
14 6
24 12
Output:
6012
42
24
*/
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment