code.club
標題:
檢查某數是否為質數
[打印本頁]
作者:
python
時間:
2020-11-22 13:36
標題:
檢查某數是否為質數
def isprime(num):
is_prime = 1
for i in range(2,num//2):
if num%i==0:
is_prime = 0
break
if is_prime == 1:
print(num,"is a prime.")
else:
print(num,'is NOT a prime!!')
歡迎光臨 code.club (https://code.club/)
Powered by Discuz! X3.2