当“ num”值达到31或61或67等时,程序就停止工作(通过手动更改num值找到这些数字)
temp_total = 0
num = 1
while True:
print(num)
check = (2**num)-1
for r in range(1, check+1):
if check!=1 and r!=1 and r!=check:
if check%r == 0:
temp_total += 1
break
if temp_total == 0 and check != 1:
print('\n\nThe value of n in the equation is ', num)
print('The prime number is ', check)
calculate = (2**(num-1))*((2**num)-1)
print('The perfect number is ', calculate, '\n\n\n')
temp_total = 0
num += 1
我希望程序能够连续运行,而不是在'num'达到随机值时停止运行。