Skip to content

Instantly share code, notes, and snippets.

@MiSawa
Created August 25, 2012 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MiSawa/3464115 to your computer and use it in GitHub Desktop.
Save MiSawa/3464115 to your computer and use it in GitHub Desktop.
$facto = [1]
for i in 1..10
$facto[i] = $facto[i-1] * i
end
def f(n)
res = 0
until n.zero?
res += $facto[n%10]
n /= 10
end
res
end
m = 1
m += 1 while $facto[9] * m >= 10**m
res = 0
for i in 3...(10**m)
res += i if f(i) == i
end
p res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment