cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A061602 Sum of factorials of the digits of n.

This page as a plain text file.
%I A061602 #52 Feb 16 2025 08:32:44
%S A061602 1,1,2,6,24,120,720,5040,40320,362880,2,2,3,7,25,121,721,5041,40321,
%T A061602 362881,3,3,4,8,26,122,722,5042,40322,362882,7,7,8,12,30,126,726,5046,
%U A061602 40326,362886,25,25,26,30,48,144,744,5064,40344,362904,121,121,122,126
%N A061602 Sum of factorials of the digits of n.
%C A061602 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 A061602 The sum of factorials of the digits is the same for 0, 1, 2 in any base. - _Alonso del Arte_, Oct 21 2012
%H A061602 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 A061602 Project Euler, <a href="https://projecteuler.net/problem=74">Problem 74: Digit factorial chains</a>
%H A061602 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 A061602 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/Factorion.html">Factorion.</a>
%e A061602 a(24) = (2!) + (4!) = 2 + 24 = 26.
%e A061602 a(153) = 127 because 1! + 5! + 3! = 1 + 120 + 6 = 127.
%p A061602 A061602 := proc(n)
%p A061602         add(factorial(d),d=convert(n,base,10)) ;
%p A061602 end proc: # _R. J. Mathar_, Dec 18 2011
%t A061602 a[n_] := Total[IntegerDigits[n]! ]; Table[a[n], {n, 1, 53}] (* Saif Hakim (saif7463(AT)gmail.com), Apr 23 2006 *)
%o A061602 (PARI) a(n) = { if(n==0, 1, my(d=digits(n)); sum(i=1, #d, d[i]!)) } \\ _Harry J. Smith_, Jul 25 2009
%o A061602 (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 A061602 (Python)
%o A061602 import math
%o A061602 def A061602(n):
%o A061602     s=0
%o A061602     for i in str(n):
%o A061602         s+=math.factorial(int(i))
%o A061602     return s # _Indranil Ghosh_, Jan 11 2017
%o A061602 (R)
%o A061602 i=0
%o A061602 values <- c()
%o A061602 while (i<1000) {
%o A061602   values[i+1] <- A061602(i)
%o A061602   i=i+1
%o A061602 }
%o A061602 plot(values)
%o A061602 A061602 <- function(n) {
%o A061602   sum=0;
%o A061602   numberstring <- paste0(i)
%o A061602   numberstring_split <- strsplit(numberstring, "")[[1]]
%o A061602   for (number in numberstring_split) {
%o A061602     sum = sum+factorial(as.numeric(number))
%o A061602   }
%o A061602   return(sum)
%o A061602 }
%o A061602 # _Raphaƫl Deknop_, Nov 08 2021
%Y A061602 Cf. A061603, A108911, A193163, A165451 (places of primes).
%Y A061602 See also A014080, A214285, A254499, A306955.
%K A061602 nonn,base,easy
%O A061602 0,3
%A A061602 _Amarnath Murthy_, May 19 2001
%E A061602 Corrected and extended by _Vladeta Jovovic_, May 19 2001
%E A061602 Link and amended comment by Mark Hudson (mrmarkhudson(AT)hotmail.com), Nov 12 2004