#include<stdio.h> int gcd2(int , int ); int main(void){ int p, q;
printf("\n%dと%dの最大公約数を求める\n", p, q); printf("%dと%dの最大公約数は%dである。\n",p, q, gcd2(p,q)); return 0; }
int gcd2(int p, int q) { int r = p%q; if (r == 0) { printf("p = %4d, q = %4d, r = %4d \n", p, q, r); return q ; } else { printf("gcd2(%4d, %4d) = gcd2(%4d, %4d)\n", p, q, q, r); return gcd2(q, r); } }