Skip to content

Instantly share code, notes, and snippets.

@shieldsd
Created April 3, 2012 09:33
Show Gist options
  • Select an option

  • Save shieldsd/2290669 to your computer and use it in GitHub Desktop.

Select an option

Save shieldsd/2290669 to your computer and use it in GitHub Desktop.
Project Euler #40
from operator import mul
from itertools import takewhile
def nth():
i = 1
s = '1'
while 1:
yield i, s[i - 1]
i += 1
s += str(i)
print reduce(mul,
(int(c) for (i, c) in
(takewhile(lambda(i, c): i <= 1000000, nth()))
if i in (1, 10, 100, 1000, 10000, 100000, 1000000)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment