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.

A034886 Number of digits in n!.

This page as a plain text file.
%I A034886 #94 Jan 03 2025 10:57:17
%S A034886 1,1,1,1,2,3,3,4,5,6,7,8,9,10,11,13,14,15,16,18,19,20,22,23,24,26,27,
%T A034886 29,30,31,33,34,36,37,39,41,42,44,45,47,48,50,52,53,55,57,58,60,62,63,
%U A034886 65,67,68,70,72,74,75,77,79,81,82,84,86,88,90,91,93,95,97,99,101,102
%N A034886 Number of digits in n!.
%C A034886 Most counterexamples to the Kamenetsky formula (see below) must belong to A177901.
%C A034886 Noam D. Elkies reported on MathOverflow (see link):
%C A034886 "A counterexample [to Kamenetsky's formula] is n_1 := 6561101970383, with log_10((n_1/e)^n_1*sqrt(2*Pi*n_1)) = 81244041273652.999999999999995102482, but log_10(n_1!) = 81244041273653.000000000000000618508. [...] n_1 is the first counterexample, and the only one up to 10^14."
%C A034886 From _Bernard Schott_, Dec 07 2019: (Start)
%C A034886 a(n) < n iff 2 <= n <= 21;
%C A034886 a(n) = n iff n = 1, 22, 23, 24;
%C A034886 a(n) > n iff n = 0 or n >= 25. (End)
%D A034886 Martin Gardner, "Factorial Oddities." Ch. 4 in Mathematical Magic Show: More Puzzles, Games, Diversions, Illusions and Other Mathematical Sleight-of-Mind from Scientific American. New York: Vintage, pp. 50-65, 1978
%H A034886 T. D. Noe, <a href="/A034886/b034886.txt">Table of n, a(n) for n = 0..10000</a>
%H A034886 Noam D. Elkies, <a href="http://mathoverflow.net/questions/19170">A counterexample to Kamenetsky's formula for the number of digits in n-factorial</a>.
%H A034886 Wikipedia, <a href="http://en.wikipedia.org/wiki/Stirling&#39;s_approximation">Stirling's Formula</a>.
%H A034886 <a href="/index/Fa#factorial">Index entries for sequences related to factorial numbers</a>.
%F A034886 a(n) = floor(log(n!)/log(10)) + 1.
%F A034886 a(n) = A027869(n) + A079680(n) + A079714(n) + A079684(n) + A079688(n) + A079690(n) + A079691(n) + A079692(n) + A079693(n) + A079694(n); a(n) = A055642(A000142(n)). - _Reinhard Zumkeller_, Jan 27 2008
%F A034886 Using Stirling's formula we can derive an approximation, which is very fast to compute in practice: ceiling(log_10(2*Pi*n)/2 + n*(log_10(n/e))). This approximation gives the exact answer for 2 <= n <= 5*10^7. - _Dmitry Kamenetsky_, Jul 07 2008
%F A034886 a(n) = ceiling(log_10(1) + log_10(2) + ... + log_10(n)). - _Dmitry Kamenetsky_, Nov 05 2010
%p A034886 A034886 := n -> `if`(n<2,1,`if`(n<6561101970383, ceil((ln(2*Pi)-2*n+ln(n)*(1+2*n))/(2*ln(10))),length(n!))); # _Peter Luschny_, Aug 26 2011
%t A034886 Join[{1, 1}, Table[Ceiling[Log[10, 2 Pi n]/2 + n*Log[10, n/E]], {n, 2, 71}]]
%t A034886 f[n_] := Floor[(Log[2Pi] - 2n + Log[n]*(1 + 2n))/(2Log[10])] + 1; f[0] = f[1] = 1; Array[f, 72, 0] (* _Robert G. Wilson v_, Jan 09 2013 *)
%t A034886 IntegerLength/@(Range[0,80]!) (* _Harvey P. Dale_, Aug 07 2022 *)
%o A034886 (Haskell)
%o A034886 a034886 = a055642 . a000142  -- _Reinhard Zumkeller_, Apr 08 2012
%o A034886 (PARI) for(n=0,30, print1(floor(log(n!)/log(10)) + 1, ", ")) \\ _G. C. Greubel_, Feb 26 2018
%o A034886 (Magma) [Floor(Log(Factorial(n))/Log(10)) + 1: n in [0..30]]; // _G. C. Greubel_, Feb 26 2018
%Y A034886 Cf. A000142, A055642.
%Y A034886 Cf. A006488 (a(n) is a square), A056851 (a(n) is a cube), A035065 (a(n) is a prime), A333431 (a(n) is a factorial), A333598 (a(n) is a palindrome), A067367 (p and a(p) are primes), A058814 (n divides a(n)).
%Y A034886 Cf. A137580 (number of distinct digits in n!), A027868 (number of trailing zeros in n!).
%K A034886 nonn,base,easy
%O A034886 0,5
%A A034886 _Erich Friedman_
%E A034886 Explained that the formula is an approximation. Made the formula easier to read. - _Dmitry Kamenetsky_, Dec 15 2010