Skip to content

Instantly share code, notes, and snippets.

@shieldsd
Created April 20, 2012 15:49
Show Gist options
  • Save shieldsd/2429838 to your computer and use it in GitHub Desktop.
Save shieldsd/2429838 to your computer and use it in GitHub Desktop.
Project Euler #47
from itertools import count, islice
from operator import and_
def factorise(n):
result = []
check = 2
while (check * check <= n):
if n % check == 0:
result.append(check)
n /= check
else:
check += 1
if n != 1:
result.append(n)
return set(result)
print (i for i in count(1)
if reduce(and_, map(lambda x: len(x) == 4,
map(factorise, islice(count(i), 4))))).next()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment