快速指数算法+python代码
2020-12-13 23:00
标签:代码 range def 图片 nbsp his code length img 算法原理:
Python代码: 快速指数算法+python代码 标签:代码 range def 图片 nbsp his code length img 原文地址:https://www.cnblogs.com/kexve/p/11622336.html1 def kuaiSuZhiShu(di, zhiShu, mod):2 zhiShu2 = bin(zhiShu)[2:]3 length = len(zhiShu2)4 jieGuo = di**int(zhiShu2[0])5 for i in range(1, length):6 jieGuo = jieGuo**2 % mod7 jieGuo = jieGuo*di**int(zhiShu2[i]) % mod8 return jieGuo9 print(kuaiSuZhiShu(11, 23, 187))