def how_many_prime(n):
total = 0
for i in range(n+1):
is_prime = True
if i>=2:
for j in range(i):
if j>1 and i%j==0:
is_prime = False
break
if is_prime == True:
total += 1
print(i," is a prime.")
print("There are",total,"prime numbers in",n,".")作者: CDC 時間: 2020-11-25 18:28
def prime_check(num):
total = 0
for i in range(2,num+1):
is_prime = True
for j in range(2,i//2+1):
if i%j==0:
is_prime=False
break
if is_prime==True:
total += 1
print(i,'is a prime.',end=' ')
print("There are",total,"prime numbers.")