In [4]:
every_other = 0
for num in range(1,101):
prime = True
for i in range(2,num):
if (num%i==0):
prime = False
if prime:
every_other += 1
if (every_other%2==0):
print(num)
I think this should be faster, but it's hard to tell:
In [19]:
every_other = 0
primes = []
for num in range(2,101):
prime = True
for i in primes:
if (num%i==0):
prime = False
if prime:
every_other += 1
primes.append(num)
if (every_other%2==1):
print(num)
In [ ]: