0
Write a program to create a function to accept N number return how many prime number.
3 Respuestas
+ 1
def isPrime(number):
numbers = range(2,number)
for i in numbers:
if number % i == 0:
return False
break
return True
count = 0
user = int(input("give a number"))
for i in range(2,user+1):
if isPrime(i):
count += 1
print("The number of prime ",count)
0
To optimize that i would divide by 2 the "number" in line 2. actually i have made one of these, check if You want
0
Hmm. I saw your code and i really appreciate it.