Advertisement
skashminzim

gcd using recursion-1

Sep 22nd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.28 KB | None | 0 0
  1. #include<stdio.h>
  2. int gcd(int a,int b)
  3. {
  4.     int t;
  5.     t=a%b;
  6.     if(t==0)
  7.         return b;
  8.     else
  9.         return gcd(b,t);
  10. }
  11. main()
  12. {
  13.     int l,h,k;
  14.     if(l>h)
  15.         k=l;
  16.             l=h;
  17.             h=k;
  18.     scanf("%d%d",&h,&l);
  19.     printf("%d",gcd(h,l));
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement