fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int x, y;
  5. scanf("%d %d", &x, &y);
  6.  
  7. while (x != y) {
  8. if (x > y) {
  9. x = x - y;
  10. } else {
  11. y = y - x;
  12. }
  13. }
  14.  
  15. printf("最大公約数は %d\n", x);
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 5320KB
stdin
80 6
stdout
最大公約数は 2