I'm trying to write a prime number checker according to : Prime equations
My code so far looks like this:
def primer(x):
prime = False
x = math.sqrt(x)
if type(x) == float:
x = math.ceil(x)
for i in range(3,x + 1):
if (i % 2) == 1:
prime == True
print(prime)
Trying with 37 as primer(37) ---> sqrt(37) is 6.08
rounded to 7
7 mod 3 is = 1 ( Prime number )
I have no clue with that prime var is not updating. Could someone shed a light please ?
Edit : Linking some repl -> Repl Link
Aucun commentaire:
Enregistrer un commentaire