再帰方式を用いて最大公約数と最小公倍数を求める
1238 ワード
#include
int gcd (int a,int b)
{ if(a%b==0)
return b;
else
return gcd(b,a%b);
}
int main()
{
int m,n,t1;
printf("please input two integer number:");
scanf("%d%d",&m,&n);
t1=gcd(m,n);
printf("The highest common divisor is %d
",t1);/* */
printf("The least common multiple is %d
",m*n/t1);/* */
return 0;
}