Created
February 10, 2012 22:16
-
-
Save djipko/1793463 to your computer and use it in GitHub Desktop.
Solution to Embedly problem #1
This file contains 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
from math import factorial | |
from operator import add | |
from itertools import count | |
def R(n): | |
return reduce(add, map(int, str(factorial(n)))) | |
if __name__ == "__main__": | |
#Brute force works just fine on my makbook air so... | |
for n in count(): | |
Rn = R(n) | |
if Rn == 8001: | |
print "The lowest number whose R is 8001 is %d" %n | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment