0
我有一个代码,我需要找到一个数字的主要因素。在发现主要因素后,我需要知道如何破解我的代码,所以当它达到1.我刚刚开始使用python进行编码,并且我还没有和其他馆藏一起使用familiair,所以我想知道是否可以制作一个只打破常规的Python代码。 NUM达到1python打破嵌套循环与多个if功能
num = int(input("Give me a number:"))
priemgetallen = []
for reeks in range(2, num+1):
print(reeks)
for priemgetal in range(2,reeks):
if reeks % priemgetal != 0:
print(priemgetal)
if num%priemgetal == 0:
print("This is the old num", num)
num = num/priemgetal
print("This is the new num", num)
priemgetallen.append(priemgetal)
if num > 1:
if num%priemgetal == 0:
print("This is the new num", num)
num = num/priemgetal
print("This is the old num", num)
priemgetallen.append(priemgetal)
else:
print(priemgetallen)
break
else:
print("Num stays old")
print(priemgetallen)
就像break语句一样,你可以返回你的语句。 –