# I dont know whats wrong with my code I've tried a few different methods and I still get stuck on 9

#1

6.is_prime

Oops, try again. Your function fails on is_prime(9). It returns True when it should return False.

``````import math
def is_prime(x):
if x<2:
return False
elif x==2:
return True
elif x % 2*math.sqrt(x) == 0:
return False
else:
return True``````

#2

What you've got right now does three comparisons, is that really enough to determine if any number is prime?

What do you have to do to manually determine if a value is prime? Your code would have to do the same things, wouldn't it?

#3

I not sure I understand the math please enlighten me

#4

Searching for information like this needs to become second nature to you, it is but a google search away.
This explains one way to determine whether a number is prime, it is essentially saying the same thing that the exercise instructions already do https://en.wikipedia.org/wiki/Prime_number#Trial_division

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.