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.

Showing 1-10 of 23 results. Next

A027868 Number of trailing zeros in n!; highest power of 5 dividing n!.

Original entry on oeis.org

0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 18, 18, 18, 18, 18, 19
Offset: 0

Views

Author

Keywords

Comments

Also the highest power of 10 dividing n! (different from A054899). - Hieronymus Fischer, Jun 18 2007
Alternatively, a(n) equals the expansion of the base-5 representation A007091(n) of n (i.e., where successive positions from right to left stand for 5^n or A000351(n)) under a scale of notation whose successive positions from right to left stand for (5^n - 1)/4 or A003463(n); for instance, n = 7392 has base-5 expression 2*5^5 + 1*5^4 + 4*5^3 + 0*5^2 + 3*5^1 + 2*5^0, so that a(7392) = 2*781 + 1*156 + 4*31 + 0*6 + 3*1 + 2*0 = 1845. - Lekraj Beedassy, Nov 03 2010
Partial sums of A112765. - Hieronymus Fischer, Jun 06 2012
Also the number of trailing zeros in A000165(n) = (2*n)!!. - Stefano Spezia, Aug 18 2024

Examples

			a(100)  = 24.
a(10^3) = 249.
a(10^4) = 2499.
a(10^5) = 24999.
a(10^6) = 249998.
a(10^7) = 2499999.
a(10^8) = 24999999.
a(10^9) = 249999998.
a(10^n) = 10^n/4 - 3 for 10 <= n <= 15 except for a(10^14) = 10^14/4 - 2. - _M. F. Hasler_, Dec 27 2019
		

References

  • M. 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, 1978, pp. 50-65.

Crossrefs

See A000966 for the missing numbers. See A011371 and A054861 for analogs involving powers of 2 and 3.
Cf. also A000142, A004154.

Programs

  • Haskell
    a027868 n = sum $ takeWhile (> 0) $ map (n `div`) $ tail a000351_list
    -- Reinhard Zumkeller, Oct 31 2012
    
  • Magma
    [Valuation(Factorial(n), 5): n in [0..80]]; // Bruno Berselli, Oct 11 2021
  • Maple
    0, seq(add(floor(n/5^i),i=1..floor(log[5](n))), n=1..100); # Robert Israel, Nov 13 2014
  • Mathematica
    Table[t = 0; p = 5; While[s = Floor[n/p]; t = t + s; s > 0, p *= 5]; t, {n, 0, 100} ]
    Table[ IntegerExponent[n!], {n, 0, 80}] (* Robert G. Wilson v *)
    zOF[n_Integer?Positive]:=Module[{maxpow=0},While[5^maxpow<=n,maxpow++];Plus@@Table[Quotient[n,5^i],{i,maxpow-1}]]; Attributes[zOF]={Listable}; Join[{0},zOF[ Range[100]]] (* Harvey P. Dale, Apr 11 2022 *)
  • PARI
    a(n)={my(s);while(n\=5,s+=n);s} \\ Charles R Greathouse IV, Nov 08 2012, edited by M. F. Hasler, Dec 27 2019
    
  • PARI
    a(n)=valuation(n!,5) \\ Charles R Greathouse IV, Nov 08 2012
    
  • PARI
    apply( A027868(n)=(n-sumdigits(n,5))\4, [0..99]) \\ M. F. Hasler, Dec 27 2019
    
  • Python
    from sympy import multiplicity
    A027868, p5 = [0,0,0,0,0], 0
    for n in range(5,10**3,5):
        p5 += multiplicity(5,n)
        A027868.extend([p5]*5) # Chai Wah Wu, Sep 05 2014
    
  • Python
    def A027868(n): return 0 if n<5 else n//5 + A027868(n//5) # David Radcliffe, Jun 26 2016
    
  • Python
    from sympy.ntheory.factor_ import digits
    def A027868(n): return n-sum(digits(n,5)[1:])>>2 # Chai Wah Wu, Oct 18 2024
    

Formula

a(n) = Sum_{i>=1} floor(n/5^i).
a(n) = (n - A053824(n))/4.
From Hieronymus Fischer, Jun 25 2007 and Aug 13 2007, edited by M. F. Hasler, Dec 27 2019: (Start)
G.f.: g(x) = Sum_{k>0} x^(5^k)/(1-x^(5^k))/(1-x).
a(n) = Sum_{k=5..n} Sum_{j|k, j>=5} (floor(log_5(j)) - floor(log_5(j-1))).
G.f.: g(x) = L[b(k)](x)/(1-x) where L[b(k)](x) = Sum_{k>=0} b(k)*x^k/(1-x^k) is a Lambert series with b(k) = 1, if k>1 is a power of 5, else b(k) = 0.
G.f.: g(x) = Sum_{k>0} c(k)*x^k/(1-x), where c(k) = Sum_{j>1, j|k} floor(log_5(j)) - floor(log_5(j - 1)).
Recurrence:
a(n) = floor(n/5) + a(floor(n/5));
a(5*n) = n + a(n);
a(n*5^m) = n*(5^m-1)/4 + a(n).
a(k*5^m) = k*(5^m-1)/4, for 0 <= k < 5, m >= 0.
Asymptotic behavior:
a(n) = n/4 + O(log(n)),
a(n+1) - a(n) = O(log(n)), which follows from the inequalities below.
a(n) <= (n-1)/4; equality holds for powers of 5.
a(n) >= n/4 - 1 - floor(log_5(n)); equality holds for n = 5^m-1, m > 0.
lim inf (n/4 - a(n)) = 1/4, for n -> oo.
lim sup (n/4 - log_5(n) - a(n)) = 0, for n -> oo.
lim sup (a(n+1) - a(n) - log_5(n)) = 0, for n -> oo.
(End)
a(n) <= A027869(n). - Reinhard Zumkeller, Jan 27 2008
10^a(n) = A000142(n) / A004154(n). - Reinhard Zumkeller, Nov 24 2012
a(n) = Sum_{k=1..floor(n/2)} floor(log_5(n/k)). - Ammar Khatab, Feb 01 2025

Extensions

Examples added by Hieronymus Fischer, Jun 06 2012

A034886 Number of digits in n!.

Original entry on oeis.org

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, 29, 30, 31, 33, 34, 36, 37, 39, 41, 42, 44, 45, 47, 48, 50, 52, 53, 55, 57, 58, 60, 62, 63, 65, 67, 68, 70, 72, 74, 75, 77, 79, 81, 82, 84, 86, 88, 90, 91, 93, 95, 97, 99, 101, 102
Offset: 0

Views

Author

Keywords

Comments

Most counterexamples to the Kamenetsky formula (see below) must belong to A177901.
Noam D. Elkies reported on MathOverflow (see link):
"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."
From Bernard Schott, Dec 07 2019: (Start)
a(n) < n iff 2 <= n <= 21;
a(n) = n iff n = 1, 22, 23, 24;
a(n) > n iff n = 0 or n >= 25. (End)

References

  • 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

Crossrefs

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)).
Cf. A137580 (number of distinct digits in n!), A027868 (number of trailing zeros in n!).

Programs

  • Haskell
    a034886 = a055642 . a000142  -- Reinhard Zumkeller, Apr 08 2012
    
  • Magma
    [Floor(Log(Factorial(n))/Log(10)) + 1: n in [0..30]]; // G. C. Greubel, Feb 26 2018
  • Maple
    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
  • Mathematica
    Join[{1, 1}, Table[Ceiling[Log[10, 2 Pi n]/2 + n*Log[10, n/E]], {n, 2, 71}]]
    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 *)
    IntegerLength/@(Range[0,80]!) (* Harvey P. Dale, Aug 07 2022 *)
  • PARI
    for(n=0,30, print1(floor(log(n!)/log(10)) + 1, ", ")) \\ G. C. Greubel, Feb 26 2018
    

Formula

a(n) = floor(log(n!)/log(10)) + 1.
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
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
a(n) = ceiling(log_10(1) + log_10(2) + ... + log_10(n)). - Dmitry Kamenetsky, Nov 05 2010

Extensions

Explained that the formula is an approximation. Made the formula easier to read. - Dmitry Kamenetsky, Dec 15 2010

A079692 Number of 7's in n!.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 3, 0, 1, 2, 6, 2, 1, 0, 0, 1, 1, 3, 0, 4, 1, 1, 2, 2, 4, 3, 4, 4, 4, 3, 3, 4, 4, 4, 1, 2, 8, 5, 5, 3, 8, 5, 7, 4, 9, 4, 4, 7, 7, 6, 8, 8, 3, 9, 8, 6, 8, 8, 9, 10, 12, 7, 7, 9, 9, 7, 10, 10, 9, 14, 11, 12, 9, 7, 13, 17, 2, 11, 12, 19, 15, 12, 10, 15, 15, 16, 19, 7, 7, 12
Offset: 0

Views

Author

Cino Hilliard, Jan 31 2003

Keywords

Crossrefs

Programs

  • Maple
    a:= n-> numboccur(7, convert(n!, base, 10)):
    seq(a(n), n=0..101);  # Alois P. Heinz, Apr 26 2021
  • PARI
    a(n) = #select(x->(x==7), digits(n!)); \\ Michel Marcus, Apr 26 2021

Formula

a(n) = A034886(n) - (A027869(n) + A079680(n) + A079714(n) + A079684(n) + A079688(n) + A079690(n) + A079691(n) + A079693(n) + A079694(n)). - Reinhard Zumkeller, Jan 27 2008

Extensions

a(78)-a(79) corrected by Georg Fischer, Apr 26 2021

A137579 Frequency of occurrence of the least frequent digits of decimal representation of n!.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 2, 1, 2, 2, 0, 2, 3, 0, 3, 2, 2, 3, 1, 2, 3, 2, 2, 3, 3, 2, 3, 4, 1, 4, 4, 5, 3, 3, 4, 4, 3, 5, 3, 6, 6, 4, 5, 5, 3, 5, 5, 7, 7, 6, 6, 4, 5, 8, 1, 8, 8, 5, 8, 7, 2, 6, 10, 6, 7, 7, 7, 8, 7, 11, 6, 7, 7
Offset: 0

Views

Author

Reinhard Zumkeller, Jan 27 2008

Keywords

Comments

a(n)=Min{A027869(n),A079680(n),A079714(n),A079684(n),A079688(n),A079690(n),A079691(n),A079692(n),A079693(n),A079694(n)}.
a(n) = 0 iff A137580(n) < 10.

Crossrefs

Programs

  • Mathematica
    Table[Min[DigitCount[n!]],{n,0,110}] (* Harvey P. Dale, Aug 21 2012 *)

A079680 Number of 1's in n!.

Original entry on oeis.org

1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 2, 1, 0, 0, 0, 3, 1, 3, 2, 1, 1, 4, 3, 3, 4, 4, 3, 2, 5, 7, 2, 4, 4, 4, 7, 3, 6, 6, 6, 4, 6, 7, 4, 10, 4, 5, 7, 10, 3, 2, 5, 5, 4, 7, 10, 6, 8, 3, 8, 9, 12, 5, 5, 8, 11, 9, 7, 6, 6, 16, 13, 9, 7, 7, 11, 15, 8, 9, 13, 10, 15, 13, 8, 14, 14, 12, 11, 12, 13, 16, 11
Offset: 0

Views

Author

Cino Hilliard, Jan 31 2003

Keywords

Crossrefs

Formula

a(n) = A034886(n) - (A027869(n) + A079714(n) + A079684(n) + A079688(n) + A079690(n) + A079691(n) + A079692(n) + A079693(n) + A079694(n)). - Reinhard Zumkeller, Jan 27 2008

A079684 Number of 3's in n!.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 2, 0, 1, 2, 1, 1, 0, 0, 1, 5, 3, 2, 1, 3, 3, 2, 1, 7, 2, 3, 7, 4, 5, 1, 5, 3, 5, 3, 9, 3, 5, 1, 5, 7, 6, 6, 6, 4, 9, 8, 5, 3, 4, 5, 8, 8, 4, 8, 5, 9, 7, 7, 6, 9, 10, 5, 7, 8, 6, 10, 7, 11, 7, 9, 10, 8, 8, 15, 10, 13, 8, 10, 13, 8, 12, 10, 6, 18, 12, 12, 15, 9, 12
Offset: 0

Views

Author

Cino Hilliard, Jan 31 2003

Keywords

Crossrefs

Programs

  • Mathematica
    DigitCount[Range[0,100]!,10,3] (* Harvey P. Dale, Jul 04 2014 *)

Formula

a(n) = A034886(n) - (A027869(n) + A079680(n) + A079714(n) + A079688(n) + A079690(n) + A079691(n) + A079692(n) + A079693(n) + A079694(n)). - Reinhard Zumkeller, Jan 27 2008

Extensions

Corrected by Jason Earls, Jul 06 2003

A079688 Number of 4's in n!.

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 2, 2, 3, 1, 2, 4, 2, 3, 2, 4, 3, 1, 1, 0, 3, 4, 3, 3, 3, 3, 3, 4, 3, 6, 2, 5, 4, 3, 3, 4, 3, 7, 3, 5, 7, 6, 6, 13, 8, 8, 7, 10, 4, 4, 8, 10, 8, 16, 10, 7, 13, 6, 5, 10, 7, 7, 13, 11, 11, 10, 4, 13, 13, 16, 10, 8, 15, 14, 10, 18, 6, 13, 12, 17, 12
Offset: 0

Views

Author

Cino Hilliard, Jan 31 2003

Keywords

Crossrefs

Programs

  • Mathematica
    DigitCount[#,10,4]&/@(Range[0,100]!) (* Harvey P. Dale, Jul 30 2015 *)

Formula

a(n) = A034886(n) - (A027869(n) + A079680(n) + A079714(n) + A079684(n) + A079690(n) + A079691(n) + A079692(n) + A079693(n) + A079694(n)). - Reinhard Zumkeller, Jan 27 2008

A079690 Number of 5's in n!.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 0, 1, 0, 2, 0, 3, 3, 2, 2, 2, 4, 3, 1, 2, 2, 2, 2, 5, 1, 2, 5, 6, 5, 7, 5, 5, 8, 5, 6, 5, 2, 4, 7, 3, 3, 11, 5, 6, 5, 5, 3, 7, 6, 4, 7, 10, 3, 7, 8, 5, 10, 7, 3, 7, 13, 9, 10, 6, 9, 7, 14, 13, 1, 12, 8, 13, 13, 11, 10, 10, 12, 17, 17, 14, 15, 12
Offset: 0

Views

Author

Cino Hilliard, Jan 31 2003

Keywords

Crossrefs

Programs

  • Mathematica
    DigitCount[#,10,5]&/@(Range[0,100]!) (* Harvey P. Dale, Sep 17 2016 *)

Formula

a(n) = A034886(n) - (A027869(n) + A079680(n) + A079714(n) + A079684(n) + A079688(n) + A079691(n) + A079692(n) + A079693(n) + A079694(n)). - Reinhard Zumkeller, Jan 27 2008

A079691 Number of 6's in n!.

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 2, 0, 2, 1, 1, 2, 0, 2, 3, 2, 0, 4, 3, 2, 3, 3, 2, 5, 3, 4, 7, 2, 3, 5, 2, 3, 6, 5, 6, 5, 8, 4, 7, 6, 6, 9, 5, 8, 7, 3, 9, 6, 7, 4, 6, 8, 6, 6, 11, 6, 8, 8, 11, 6, 4, 11, 11, 10, 6, 5, 9, 8, 9, 8, 11, 10, 8, 11, 12, 13, 9, 11, 7, 12, 15, 15, 17, 8, 11, 16, 11
Offset: 0

Views

Author

Cino Hilliard, Jan 31 2003

Keywords

Crossrefs

Programs

  • Mathematica
    Table[DigitCount[n!,10,6],{n,0,100}] (* Harvey P. Dale, Aug 08 2023 *)

Formula

a(n) = A034886(n) - (A027869(n) + A079680(n) + A079714(n) + A079684(n) + A079688(n) + A079690(n) + A079692(n) + A079693(n) + A079694(n)). - Reinhard Zumkeller, Jan 27 2008

A079693 Number of 8's in n!.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 1, 0, 1, 2, 1, 4, 2, 1, 2, 1, 0, 1, 4, 1, 2, 1, 6, 4, 2, 5, 6, 2, 8, 2, 1, 3, 2, 0, 7, 4, 2, 4, 2, 9, 3, 7, 4, 4, 7, 5, 5, 9, 8, 9, 4, 11, 7, 10, 9, 4, 11, 7, 7, 12, 7, 9, 9, 7, 8, 14, 18, 15, 9, 9, 10, 8, 18, 12, 14, 13, 8, 10, 8, 12, 5, 8, 8, 18, 10, 14, 9, 11, 12, 16
Offset: 0

Views

Author

Cino Hilliard, Jan 31 2003

Keywords

Crossrefs

Programs

  • Mathematica
    Table[DigitCount[n!,10,8],{n,0,100}] (* Harvey P. Dale, May 06 2016 *)

Formula

a(n) = A034886(n) - (A027869(n) + A079680(n) + A079714(n) + A079684(n) + A079688(n) + A079690(n) + A079691(n) + A079692(n) + A079694(n)). - Reinhard Zumkeller, Jan 27 2008
Showing 1-10 of 23 results. Next