prime = int(raw_input())
out = ''
while prime != -1:
countPrime = 0
for i in range(0,prime):
if prime == 2 or prime == 3:
out = "is a prime"
elif prime % 2 == 0 or prime %3 == 0 or prime ==1:
out = "not a prime"
else:
out = "is a prime"
prime -= 1
if out == 'is a prime':
countPrime += 1
print countPrime
prime = int(raw_input())
the program is meant to count the number of prime numbers that fall under the the entered number.
this only works for smaller numbers once the number is too big, it outputs the wrong count
1000 is meant to 168, but rather gives 333??
please help

New Topic/Question
Reply



MultiQuote



|