I am trying to code a prime number finder in python. This is not some kind of assignment, but purely for fun. Somehow, the program gives me wrong answers! But I really cant find out why... maybe you guys could help me? I would be really grateful.
My code:
def is_prime(n):
if n == 0 or n == 1:
print(n, "is prime")
return true
else:
for i in range(2, ((n+1)/2)):
if n%i == 0:
print(n, " isn't prime.")
return false
else:
print(n, " is prime.")
return true