fork download
  1. #include<stdio.h>
  2. int gcd(int x, int y)
  3. { int a;
  4. while(y != 0)
  5. { a=x%y;
  6. x=y;
  7. y=a; }
  8. return x; }
  9.  
  10. int main()
  11. { int num1,num2;
  12. scanf("%d %d",&num1,&num2);
  13. printf("2つの整数の最大公約数は%d",gcd(num1,num2));
  14. return 0;
  15. }
  16.  
Success #stdin #stdout 0.01s 5272KB
stdin
10
20
stdout
2つの整数の最大公約数は10