Advertisement
nisadkhan

C Gcd

Aug 30th, 2014
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int a,b,x,gcd,quite;
  5.     printf("Developed by: Nisad\nGcd:\n\n");
  6.     scanf("%d %d",&a,&b);
  7.  
  8.     if(a<b){
  9.         x=a;
  10.     }
  11.     else{
  12.         x=b;
  13.     }
  14.  
  15.     for(;x>=1;x--){
  16.         if(a % x == 0 && b % x == 0){
  17.             gcd=x;
  18.             break;
  19.         }
  20.     }
  21.     printf("Gcd is: %d",gcd);
  22.     scanf("%d",&quite);
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement