def millerRabin(toTest = 3, accuracy = 5):
# Return true if toTest is prime
################################
# Find how many times toTest can be halved
print(toTest)
under = toTest - 1
loopTracker = 0
while under % 2 == 0:
print('Before halving')
# Keep halving, and keep track until hit we can no longer divide in half
under = under // 2
print('After Halving: ', under)
loopTracker += 1
print("looped")
print(loopTracker)
print(millerRabin(toTest = 144000))
米勒-拉宾(Miller-Rabin)的第一部分是跟踪可以将测试数量减半的次数。但是,我不知道为什么程序没有进入while循环并输出一些打印语句。
答案 0 :(得分:1)
定义under
时,将减去1。这将创建143999进行测试,但不能被2整除。因此,它会使您的while条件失败,并且永远不会进入循环。