Created
July 26, 2012 21:21
-
-
Save josejuan/3184595 to your computer and use it in GitHub Desktop.
Factoriones
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
# Factorial de 'n' | |
def factorial(n): | |
if n == 0: | |
return 1 | |
return factorial(n - 1) * n | |
# Para cada número a revisar | |
for i in range(1, 2500000 + 1): | |
# Calculamos según la definición | |
j = sum([factorial(ord(j) - 48) for j in "%i" % i]) | |
# Y si coincide | |
if i == j: | |
# ¡Es un factorión! | |
print(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment