windows - python code is restarting -
as i'm proceeding project euler started learning python. although great , simple language got bit stuck.
every code wrote , tried run automatically restarting. think because of very long loop (for example, finding 10001 prime number), cant find out how fix issue. can me, give me guide line or tip?
oh, if matters im using python 2.7
thank you!
the code example:
count = 0 num = 0 = 1 def prime(num): if num <= 1: return false if num == 2: return true else: in range(3, num): if (num % i) == 0: return false break else: return true while (count < 10001): if prime(i) == true: num == count == count + 1 = + 1 print num
you need change ==
=
(twice) in while
loop:
while (count < 10001): if prime(i) == true: num = count = count + 1 = + 1
then code runs fine, , prints num
104729
Comments
Post a Comment