總覺得我和質數有心結
(因為題目說輸入的值是從2開始,所以我直接把小於等於3的數都當質數)
num = int(input())
if num <= 3:
print('yes')
elif num % 2 == 0:
print('no')
elif num % 3 == 0:
print('no')
else:
for i in range(5, int(num ** 0.5) + 1, 6):
print(f'i = {i}')
if num % i == 0:
print('no')
break
elif num % (i + 1):
print('no')
break
else:
print('yes')
|
NA(score:90%)