0

I have a problem finding GCD and LCM using C#. I considered to use a method where you break the two numbers down into two other numbers, for example breaking down 6 into 2 and 3, but I'm not sure how to do that using c#? Can someone please give me advice or a better solution?

1 Answers1

0
Num1 = a;  
Num2 = b;  
while (Num2 != 0)  
{  
    temp = Num2;  
    Num2 = Num1 % Num2;  
    Num1 = temp;  
}  
GCD = Num1;  
LCM = (a * b) / GCD; 
Miss Chanandler Bong
  • 4,081
  • 10
  • 26
  • 36