Is_prime() "Is 2238972 the highest number codecademy can work with?"



Is this the highest number that codecademy can work with? 2238972
I get a memoryerror with anything higher

def is_prime(x):
    if x <= 1:
        return False
    a = 0
    for n in range(1, x):
        if x % n == 0:
            a += 1
        if a >= 2:
        return True
    return False

print is_prime(2238973)


i can run higher numbers than that on Win XP firefox 32 bit in the codecademy python interpreter and probably would work for same or higher in different/newer OS or browser. i'm guessing it's a situational thing for your browser computer etc

out of curiosity what happen when you restart the browser then try the same again? i noticed on an exercise that it would remember old variable contents from many lessons ago as long as i never closed the session

dont worry i highly doubt the codecademy python work will have us going beyond that number o.o


Restarting the browser does increase the value I can test. Cool.


How'd you figure that out?


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