Advertisement
RAJIBRAJU

2.gcd and lcd

Jun 21st, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.23 KB | None | 0 0
  1. #include<stdio.h>
  2. int main () {
  3. int x,y,z,rem,temp;
  4. scanf("%d%d",&x,&y);
  5. temp=x;
  6. z=y;
  7. while (z!=0) {
  8.     rem=temp%z;
  9.     temp=z;
  10.     z=rem;
  11.  
  12. }
  13.  
  14. printf("GCD=%d\n",temp);
  15. printf("LCD=%d\n",(x*y)/temp);
  16.  
  17.  
  18. return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement