Advertisement
RIFATKHAN1

GCD and LCM of two Numbers.

Jun 23rd, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int num1,num2,n1,n2,rem,LCM,GCD;
  5.     scanf("%d%d",&num1,&num2);
  6.  
  7.     n1 = num1;
  8.     n2 = num2;
  9.  
  10.     while(n2!=0)
  11.     {
  12.         rem = n1%n2;
  13.         n1 = n2;
  14.         n2 = rem;
  15.     }
  16.  
  17.     GCD = n1;
  18.     LCM = num1*num2;
  19.  
  20.     printf("GCD = %d\n",GCD);
  21.     printf("LCM = %d\n",LCM);
  22.  
  23.     return 0;
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement