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


#1




memoryerror


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:
            break
    else:
        return True
    return False


print is_prime(2238973)


#2

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


#3

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


#4

How'd you figure that out?


#5

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