# 6 / 15 i dont understand why this doesnt work

#1
``````def is_prime(x):
if x < 1:
return False
elif x == 2:
return True
else:
n = 2
while n <= x-1:
if x % n != 0:
return True

else:
return False
n += 1``````

this stops at 9 and i don't understand

#2

Your function does not computer real primes, all it does is asks if a number is divisible by two.

It compute if a number is a prime you need every number from 2 to that number if any of them can divide evenly you break it.

EXAMPLE:

``````def is_prime(get_number, display=True):

prime = True

_numbers_to_number = [number for number in range(2, get_number)]

for number in _numbers_to_number:
if get_number % number == 0:
prime = False
break

if prime:
if display:
print("%s is a prime" % prime)
return get_number
elif not prime:
if display:
print("%s is not a Prime" % get_number)``````

#3

good looks . Thanks

#4

Here is an alternative.

``````def is_prime(x):
n = 2
if x < 2:
return False
else:
for n in range(2, x-1):
if x%n == 0:
return False
return True``````

#5

def is_prime(x):
if x <2:
return False
elif x ==2 :
return True
else:
n=2
while n < x :
m= x%n
if m == 0:
return False
break
n += 1
else:
return True