您的位置:首页 > 其它

递归实现最大公约数最小公倍数

2017-05-15 15:15 169 查看
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int fun(int m, int n)

{
if (m%n == 0)
{
return n;              
}
else
{
return fun(n, m%n);                        
}

}

void main()

{
int a, b;
scanf("%d%d", &a, &b);
printf("\n最大公约数=%d,最小公倍数=%d", fun(a, b), a* b / fun(b, a));
system("pause");

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: