%I #48 Feb 23 2023 10:16:28
%S 1,1,2,6,24,120,720,5040,40320,362880,2,2,3,7,25,121,721,5041,40321,
%T 362881,3,3,4,8,26,122,722,5042,40322,362882,7,7,8,12,30,126,726,5046,
%U 40326,362886,25,25,26,30,48,144,744,5064,40344,362904,121,121,122,126
%N Sum of factorials of the digits of n.
%C Numbers n such that a(n) = n are known as factorions. It is known that there are exactly four of these [in base 10]: 1, 2, 145, 40585. - _Amarnath Murthy_
%C The sum of factorials of the digits is the same for 0, 1, 2 in any base. - _Alonso del Arte_, Oct 21 2012
%H Harry J. Smith and Indranil Ghosh, <a href="/A061602/b061602.txt">Table of n, a(n) for n = 0..10000</a> (first 1001 terms from Harry J. Smith)
%H Project Euler, <a href="https://projecteuler.net/problem=74">Problem 74: Digit factorial chains</a>
%H H. J. J. te Riele, <a href="https://ir.cwi.nl/pub/6662">Iteration of number-theoretic functions</a>, Nieuw Archief v. Wiskunde, (4) 1 (1983), 345-360. See Example I.1.b.
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Factorion.html">Factorion.</a>
%e a(24) = (2!) + (4!) = 2 + 24 = 26.
%e a(153) = 127 because 1! + 5! + 3! = 1 + 120 + 6 = 127.
%p A061602 := proc(n)
%p add(factorial(d),d=convert(n,base,10)) ;
%p end proc: # _R. J. Mathar_, Dec 18 2011
%t a[n_] := Total[IntegerDigits[n]! ]; Table[a[n], {n, 1, 53}] (* Saif Hakim (saif7463(AT)gmail.com), Apr 23 2006 *)
%o (PARI) { for (n=0, 1000, a=0; x=n; until (x==0, a+=(x - 10*(x\10))!; x=x\10); write("b061602.txt", n, " ", a) ) } \\ _Harry J. Smith_, Jul 25 2009
%o (Magma) a061602:=func< n | n eq 0 select 1 else &+[ Factorial(d): d in Intseq(n) ] >; [ a061602(n): n in [0..60] ]; // _Klaus Brockhaus_, Nov 23 2010
%o (Python)
%o import math
%o def A061602(n):
%o s=0
%o for i in str(n):
%o s+=math.factorial(int(i))
%o return s # _Indranil Ghosh_, Jan 11 2017
%o (R)
%o i=0
%o values <- c()
%o while (i<1000) {
%o values[i+1] <- A061602(i)
%o i=i+1
%o }
%o plot(values)
%o A061602 <- function(n) {
%o sum=0;
%o numberstring <- paste0(i)
%o numberstring_split <- strsplit(numberstring, "")[[1]]
%o for (number in numberstring_split) {
%o sum = sum+factorial(as.numeric(number))
%o }
%o return(sum)
%o }
%o # _Raphaƫl Deknop_, Nov 08 2021
%Y Cf. A061603, A108911, A193163, A165451 (places of primes).
%Y See also A014080, A214285, A254499, A306955.
%K nonn,base,easy
%O 0,3
%A _Amarnath Murthy_, May 19 2001
%E Corrected and extended by _Vladeta Jovovic_, May 19 2001
%E Link and amended comment by Mark Hudson (mrmarkhudson(AT)hotmail.com), Nov 12 2004
|