int hcf(int n, int m)
{
int temp;
while( m > 0)
{
temp = n;
n = m;
m = temp % m;
}
return n;
}
int lcm(int n, int m) {
int product = n*m;
int hcf = hcf(n,m);
int lcm = product/hcf;
return lcm;
}
int main()
{
int n, m;
scanf("%d%d",&n,&m);
printf("%d\n",lcm(n,m));
return 0;
}
{
int temp;
while( m > 0)
{
temp = n;
n = m;
m = temp % m;
}
return n;
}
int lcm(int n, int m) {
int product = n*m;
int hcf = hcf(n,m);
int lcm = product/hcf;
return lcm;
}
int main()
{
int n, m;
scanf("%d%d",&n,&m);
printf("%d\n",lcm(n,m));
return 0;
}
This comment has been removed by the author.
ReplyDeletethanx i ws a bit confused..finally executed dis algo at raptor tool :)
ReplyDelete