求最大公约数,欧几里得辗转相除

学习连接:

https://m.baidu.com/from=0/bd_page_type=1/ssid=0/uid=0/pu=usm%400%2Csz%401320_2004%2Cta%40zbios_1_14.8_6_12.27%2Cvmgdb%400020100228y/baiduid=2633326E92C09C5A9FF0F9E62344495F/w=0_10_/t=zbios/l=1/tc?ref=www_zbios&lid=7405499374099781756&order=1&fm=alop&cyc=1&isAtom=1&clk_info=%7B%22tplname%22%3A%22wenda_abstract%22%2C%22srcid%22%3A%2228420%22%7D&is_baidu=0&tj=wenda_abstract_1_0_10_l1&wd=&eqid=66c59e71d998587c10000003618754a0&w_qd=IlPT2AEptyoA_ykz9AUcv3C6GCdSfJMp7CIXhhjSwxksMO9yPzRaxZnhi4ZtpKe&bdver=2&tcplug=1&dict=-1&sec=16516&di=aca6223f298ba0d0&bdenc=1&nsrc=k4638UOP4j5EzwRkgkRcekzhMsjJJf0HS%2FRj%2BAmuZ5F02xjw0YpnboZNOzKy%2FWSYV%2Bn2WG4Mkj3pHBjSqEO7pGAJyWwVjxvlyeAqDcIQ0S5yKnceEU5EuLp9r%2Fjatbhz

伪代码:

求最大公约数,欧几里得辗转相除

 

 

python实现:

a=int(input('yigeshu')) b=int(input('linyigeshu')) c,d=max(a,b),min(a,b) r=c%d while r!=0: c=d d=r r=c%d else: print(d)

 

上一篇:百度网址的代码


下一篇:MarkDown语法