Advertisement
lIlIlIlIIlI

ProblemSolving_gcd_1

Sep 9th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int gcd(int b,int s){
  4.     if (b >= s){
  5.         if (b % s == 0) return s;
  6.         else return gcd(s, b % s);
  7.     }
  8.     else if (b < s) return gcd(s, b);
  9. }
  10.  
  11. int main(){
  12.     int x, y;
  13.     printf("enter two numbers x, y: ");
  14.     scanf("%d,%d", &x, &y);
  15.     printf("gcd(%d, %d) = %d", x, y, gcd(x, y) );
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement