摘要: 辗转相除法最大的用途就是用来求两个数的最大公约数。 用(a,b)来表示a和b的最大公约数。 有定理: 已知a,b,c为正整数,若a除以b余c,则(a,b)=(b,c)。 (证明过程请参考其它资料) 例:求 15750 与27216的最大公约数。 解: ∵27216=15750×1+11466 ∴(1 阅读全文
posted @ 2016-12-24 23:13 legenda 阅读(1128) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ int a,b,i=1,temp,lcm; scanf("%d %d",&a,&b); if(a>b) { temp=a; a=b; b=temp; } lcm=b; if(b%a!=0) { while(lcm%a!=0) { lcm=b* 阅读全文
posted @ 2016-12-24 11:41 legenda 阅读(6031) 评论(0) 推荐(0) 编辑