Created
February 25, 2015 08:21
-
-
Save levisre/1c428446a48def383488 to your computer and use it in GitHub Desktop.
Flufferduff sCTF 2015
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sumOdd(a): | |
i=1 | |
result=0 | |
while i<a: | |
result+=i | |
i+=2 | |
return result | |
def getPrime(a): | |
result =[] | |
for i in range(2,a): | |
for j in range(2,i/2): | |
if i%j==0: | |
break | |
else: | |
result.append(i) | |
return result | |
def sumPrime(a): | |
global pList | |
result=0 | |
for i in pList: | |
if i<a: | |
result+=i | |
else: | |
return result | |
def main(): | |
c=0 | |
for i in range(0,1000): | |
if sumPrime(i)-sumOdd(i)<0: | |
c+=1 | |
print "Number of flufferduffs: %d" % c | |
pList = getPrime(1000) | |
main() |
Even when 4 is included, the answer is the same as when 4 is not included
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why does pList include 4?