num = int(input("Please input a number: ")) for i in range(2, num): for j in range(2, i): if (i % j == 0): break if (i == j + 1): print(i)
[training] Python – 質數
Leave a Comment
num = int(input("Please input a number: ")) for i in range(2, num): for j in range(2, i): if (i % j == 0): break if (i == j + 1): print(i)