Skip to content

Instantly share code, notes, and snippets.

@colegleason
Created October 8, 2010 21:13
Show Gist options
  • Save colegleason/617569 to your computer and use it in GitHub Desktop.
Save colegleason/617569 to your computer and use it in GitHub Desktop.
def isPrime(n):
if n < 2: return False
elif n == 2: return True
else:
for x in range(2, int(n**0.5)+1):
if n % x == 0:
return False
return True
def factor(n):
if n == 1: return [1]
i = 2
limit = n**0.5
while i <= limit:
if n % i == 0:
ret = factor(n/i)
ret.append(i)
return ret
i += 1
return [n]
minimum = 217000
primefib = 0
a,b = 1,0
done = False
while done == False:
if a > minimum and isPrime(a):
primefib = a
done = True
else:
b, a = a, a + b
print sum(factor(primefib + 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment