LCM of two Numbers

Manojjupally
Posted by Manojjupally under C# category on | Points: 40 | Views : 1151
LCM of Two Numbers

public static int FindLCM(int a, int b)
{
int num1, num2;
if (a > b)
{
num1 = a; num2 = b;
}
else
{
num1 = b; num2 = a;
}

for (int i = 1; i <= num2; i++)
{
if ((num1 * i) % num2 == 0)
{
return i * num1;
}
}
return num2;
}

Comments or Responses

Login to post response