Factorions: Difference between revisions
Content added Content deleted
m (Updated description and link for Fōrmulæ solution) |
|||
Line 1,079: | Line 1,079: | ||
<lang Ring> |
<lang Ring> |
||
load "stdlib.ring" |
load "stdlib.ring" |
||
see "working..." + nl |
|||
for n = |
for n = 3 to 100000 |
||
Digits = [] |
|||
sumFact = 0 |
|||
strn = string(n) |
|||
for m = 1 to len(strn) |
|||
fact = factorial(number(strn[m])) |
|||
sumFact += fact |
|||
add(Digits,fact) |
|||
next |
next |
||
if |
if sumFact = n |
||
for ind = 1 to len(strn)-1 |
|||
see "" + strn[ind] + "! + " |
|||
next |
|||
see "" + strn[ind] + "! = " |
|||
for p = 1 to len(Digits) - 1 |
|||
see "" + Digits[p] + " + " |
|||
next |
|||
factLast = Digits[p] |
|||
see "" + factLast + " = " + n + nl |
|||
ok |
ok |
||
next |
next |
||
see "done..." + nl |
|||
</lang> |
</lang> |
||
<pre> |
<pre> |
||
working... |
|||
Factorion: 1 |
|||
1! + 4! + 5! = 1 + 24 + 120 = 145 |
|||
Factorion: 2 |
|||
4! + 0! + 5! + 8! + 5! = 24 + 1 + 120 + 40320 + 120 = 40585 |
|||
Factorion: 145 |
|||
done... |
|||
Factorion: 40585 |
|||
</pre> |
</pre> |
||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
<lang ruby> |
<lang ruby> |