1 Star 0 Fork 216

bulunxier / python-learn

forked from mktime / python-learn 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
egcd.py 497 Bytes
一键复制 编辑 原始数据 按行查看 历史
内部项目 提交于 2020-12-27 23:49 . '扩展欧几里得代码备份“
p = 201522792635114097998567775554303915819
q = 236811285547763449711675622888914229291
e = 65537
n = (p-1)*(q-1)
def ext_euclid(a, b):
if b == 0:
return 1, 0, a
else:
x, y, q = ext_euclid(b, a % b) # q = gcd(a, b) = gcd(b, a%b)
x, y = y, (x - (a // b) * y)
#print(x,y,q)
return x, y, q
def test_egcd():
ret = ext_euclid(e, n)
d = ret[0]
if d < 0:
d = d + (p-1)*(q-1)
print(d)
if __name__ == '__main__':
test_egcd()
Python
1
https://gitee.com/bulunxier/python-learn.git
git@gitee.com:bulunxier/python-learn.git
bulunxier
python-learn
python-learn
master

搜索帮助