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 72 results. Next

A000788 Total number of 1's in binary expansions of 0, ..., n.

Original entry on oeis.org

0, 1, 2, 4, 5, 7, 9, 12, 13, 15, 17, 20, 22, 25, 28, 32, 33, 35, 37, 40, 42, 45, 48, 52, 54, 57, 60, 64, 67, 71, 75, 80, 81, 83, 85, 88, 90, 93, 96, 100, 102, 105, 108, 112, 115, 119, 123, 128, 130, 133, 136, 140, 143, 147, 151, 156, 159, 163, 167, 172, 176, 181, 186
Offset: 0

Views

Author

Keywords

Comments

Partial sums of A000120.
The graph of this sequence is a version of the Takagi curve: see Lagarias (2012), Section 9, especially Theorem 9.1. - N. J. A. Sloane, Mar 12 2016
a(n-1) is the largest possible number of ordered pairs (a,b) such that a/b is a prime in a subset of the positive integers with n elements. - Yifan Xie, Feb 21 2025

References

  • J.-P. Allouche & J. Shallit, Automatic sequences, Cambridge University Press, 2003, p. 94
  • R. Bellman and H. N. Shapiro, On a problem in additive number theory, Annals Math., 49 (1948), 333-340. See Eq. 1.9. [From N. J. A. Sloane, Mar 12 2009]
  • L. E. Bush, An asymptotic formula for the average sums of the digits of integers, Amer. Math. Monthly, 47 (1940), pp. 154-156. [From the bibliography of Stolarsky, 1977]
  • P. Cheo and S. Yien, A problem on the k-adic representation of positive integers (Chinese; English summary), Acta Math. Sinica, 5 (1955), pp. 433-438. [From the bibliography of Stolarsky, 1977]
  • M. P. Drazin and J. S. Griffith, On the decimal representation of integers, Proc. Cambridge Philos. Soc., (4), 48 (1952), pp. 555-565. [From the bibliography of Stolarsky, 1977]
  • E. N. Gilbert, Games of identification or convergence, SIAM Review, 4 (1962), 16-24.
  • Grabner, P. J.; Kirschenhofer, P.; Prodinger, H.; Tichy, R. F.; On the moments of the sum-of-digits function. Applications of Fibonacci numbers, Vol. 5 (St. Andrews, 1992), 263-271, Kluwer Acad. Publ., Dordrecht, 1993.
  • R. L. Graham, On primitive graphs and optimal vertex assignments, pp. 170-186 of Internat. Conf. Combin. Math. (New York, 1970), Annals of the NY Academy of Sciences, Vol. 175, 1970.
  • E. Grosswald, Properties of some arithmetic functions, J. Math. Anal. Appl., 28 (1969), pp.405-430.
  • Donald E. Knuth, The Art of Computer Programming, volume 3 Sorting and Searching, section 5.3.4, subsection Bitonic sorting, with C'(p) = a(p-1).
  • Hiu-Fai Law, Spanning tree congestion of the hypercube, Discrete Math., 309 (2009), 6644-6648 (see p(m) on page 6647).
  • Z. Li and E. M. Reingold, Solution of a divide-and-conquer maximin recurrence, SIAM J. Comput., 18 (1989), 1188-1200.
  • B. Lindström, On a combinatorial problem in number theory, Canad. Math. Bull., 8 (1965), 477-490.
  • Mauclaire, J.-L.; Murata, Leo; On q-additive functions. I. Proc. Japan Acad. Ser. A Math. Sci. 59 (1983), no. 6, 274-276.
  • Mauclaire, J.-L.; Murata, Leo; On q-additive functions. II. Proc. Japan Acad. Ser. A Math. Sci. 59 (1983), no. 9, 441-444.
  • M. D. McIlroy, The number of 1's in binary integers: bounds and extremal properties, SIAM J. Comput., 3 (1974), 255-261.
  • L. Mirsky, A theorem on representations of integers in the scale of r, Scripta Math., 15 (1949), pp. 11-12.
  • I. Shiokawa, On a problem in additive number theory, Math. J. Okayama Univ., 16 (1974), pp.167-176. [From the bibliography of Stolarsky, 1977]
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • K. B. Stolarsky, Power and exponential sums of digital sums related to binomial coefficient parity, SIAM J. Appl. Math., 32 (1977), 717-730.
  • Trollope, J. R. An explicit expression for binary digital sums. Math. Mag. 41 1968 21-25.

Crossrefs

For number of 0's in binary expansion of 0, ..., n see A059015.
The basic sequences concerning the binary expansion of n are A000120, A000788, A000069, A001969, A023416, A059015, A070939, A083652.

Programs

  • Haskell
    a000788_list = scanl1 (+) A000120_list
    -- Walt Rorie-Baety, Jun 30 2012
    
  • Haskell
    {a000788 0 = 0; a00788 n = a000788 n2 + a000788 (n-n2-1) + (n-n2) where n2 = n `div` 2}
    -- Walt Rorie-Baety, Jul 15 2012
    
  • Maple
    a:= proc(n) option remember; `if`(n=0, 0, a(n-1)+add(i, i=Bits[Split](n))) end:
    seq(a(n), n=0..62);  # Alois P. Heinz, Nov 11 2024
  • Mathematica
    a[n_] := Count[ Table[ IntegerDigits[k, 2], {k, 0, n}], 1, 2]; Table[a[n], {n, 0, 62}] (* Jean-François Alcover, Dec 16 2011 *)
    Table[Plus@@Flatten[IntegerDigits[Range[n], 2]], {n, 0, 62}] (* Alonso del Arte, Dec 16 2011 *)
    Accumulate[DigitCount[Range[0,70],2,1]] (* Harvey P. Dale, Jun 08 2013 *)
  • PARI
    A000788(n)={ n<3 && return(n); if( bittest(n,0) \\
    , n+1 == 1<A000788(n>>1)*2+n>>1+1 \\
    , n == 1<A000788(n>>=1)+A000788(n-1)+n )} \\ M. F. Hasler, Nov 22 2009
    
  • PARI
    a(n)=sum(k=1,n,hammingweight(k)) \\ Charles R Greathouse IV, Oct 04 2013
    
  • PARI
    a(n) = if (n==0, 0, m = logint(n, 2); r = n % 2^m; m*2^(m-1) + r + 1 + a(r)); \\ Michel Marcus, Mar 27 2018
    
  • PARI
    a(n)={n++; my(t, i, s); c=n; while(c!=0, i++; c\=2); for(j=1, i, d=(n\2^(i-j))%2; t+=(2^(i-j)*(s*d+d*(i-j)/2)); s+=d); t} \\ David A. Corneth, Nov 26 2024
    (C++) /* See David W. Wilson link. */
    
  • Python
    def A000788(n): return sum(i.bit_count() for i in range(1,n+1)) # Chai Wah Wu, Mar 01 2023
    
  • Python
    def A000788(n): return (n+1)*n.bit_count()+(sum((m:=1<>j)-(r if n<<1>=m*(r:=k<<1|1) else 0)) for j in range(1,n.bit_length()+1))>>1) # Chai Wah Wu, Nov 11 2024

Formula

McIlroy (1974) gives bounds and recurrences. - N. J. A. Sloane, Mar 24 2014
Stolarsky (1977) studies the asymptotics, and gives at least nine references to earlier work on the problem. I have added all the references that were not here already. - N. J. A. Sloane, Apr 06 2014
a(n) = Sum_{k=1..n} A000120(k). - Benoit Cloitre, Dec 19 2002
a(0) = 0, a(2n) = a(n)+a(n-1)+n, a(2n+1) = 2a(n)+n+1. - Ralf Stephan, Sep 13 2003
a(n) = n*log_2(n)/2 + O(n); a(2^n)=n*2^(n-1)+1. - Benoit Cloitre, Sep 25 2003 (The first result is due to Bellman and Shapiro, - N. J. A. Sloane, Mar 24 2014)
a(n) = n*log_2(n)/2+n*F(log_2(n)) where F is a nowhere differentiable continuous function of period 1 (see Allouche & Shallit). - Benoit Cloitre, Jun 08 2004
G.f.: (1/(1-x)^2) * Sum_{k>=0} x^2^k/(1+x^2^k). - Ralf Stephan, Apr 19 2003
a(2^n-1) = A001787(n) = n*2^(n-1). - M. F. Hasler, Nov 22 2009
a(4^n-2) = n(4^n-2).
For real n, let f(n) = [n]/2 if [n] even, n-[n+1]/2 otherwise. Then a(n) = Sum_{k>=0} 2^k*f((n+1)/2^k).
a(A000225(n)) = A173921(A000225(n)) = A001787(n); a(A000079(n)) = A005183(n). - Reinhard Zumkeller, Mar 04 2010
From Hieronymus Fischer, Jun 10 2012: (Start)
a(n) = (1/2)*Sum_{j=1..m+1} (floor(n/2^j + 1/2)*(2n + 2 - floor(n/2^j + 1/2))*2^j - floor(n/2^j)*(2n + 2 - (1 + floor(n/2^j)) * 2^j)), where m=floor(log_2(n)).
a(n) = (n+1)*A000120(n) - 2^(m-1) + 1/4 + (1/2)*Sum_{j=1..m+1} ((floor(n/2^j) + 1/2)^2 - floor(n/2^j + 1/2)^2)*2^j, where m=floor(log_2(n)).
a(2^m-1) = m*2^(m-1).
(This is the total number of '1' digits occurring in all the numbers with <= m bits.)
Generic formulas for the number of digits >= d in the base p representations of all integers from 0 to n, where 1<= d < p.
a(n) = (1/2)*Sum_{j=1..m+1} (floor(n/p^j + (p-d)/p)*(2n + 2 + ((p-2*d)/p - floor(n/p^j + (p-d)/p))*p^j) - floor(n/p^j)*(2n + 2 - (1+floor(n/p^j)) * p^j)), where m=floor(log_p(n)).
a(n) = (n+1)*F(n,p,d) + (1/2)*Sum_{j=1..m+1} ((((p-2*d)/p)*floor(n/p^j+(p-d)/p) + floor(n/p^j))*p^j - (floor(n/p^j+(p-d)/p)^2 - floor(n/p^j)^2)*p^j), where m=floor(log_p(n)) and F(n,p,d) = number of digits >= d in the base p representation of n.
a(p^m-1) = (p-d)*m*p^(m-1).
(This is the total number of digits >= d occurring in all the numbers with <= m digits in base p representation.)
G.f.: g(x) = (1/(1-x)^2)*Sum_{j>=0} (x^(d*p^j) - x^(p*p^j))/(1-x^(p*p^j)). (End)
a(n) = Sum_{k=1..n} A000120(A240857(n,k)). - Reinhard Zumkeller, Apr 14 2014
For n > 0, if n is written as 2^m + r with 0 <= r < 2^m, then a(n) = m*2^(m-1) + r + 1 + a(r). - Shreevatsa R, Mar 20 2018
a(n) = n*(n+1)/2 + Sum_{k=1..floor(n/2)} ((2k-1)((g(n,k)-1)*2^(g(n,k) + 1) + 2) - (n+1)*(g(n,k)+1)*g(n,k)/2), where g(n,k) = floor(log_2(n/(2k-1))). - Fabio Visonà, Mar 17 2020
From Jeffrey Shallit, Aug 07 2021: (Start)
A 2-regular sequence, satisfying the identities
a(4n+1) = -a(2n) + a(2n+1) + a(4n)
a(4n+2) = -2a(2n) + 2a(2n+1) + a(4n)
a(4n+3) = -4a(n) + 4a(2n+1)
a(8n) = 4a(n) - 8a(2n) + 5a(4n)
a(8n+4) = -9a(2n) + 5a(2n+1) + 4a(4n)
for n>=0. (End)
a(n) = Sum_{k=0..floor(log_2(n+1))} k * A360189(n,k). - Alois P. Heinz, Mar 06 2023

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Jan 15 2001

A112765 Exponent of highest power of 5 dividing n. Or, 5-adic valuation of n.

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1
Offset: 1

Views

Author

Reinhard Zumkeller, Sep 18 2005

Keywords

Comments

A027868 gives partial sums.
This is also the 5-adic valuation of Fibonacci(n). See Lengyel link. - Michel Marcus, May 06 2017

Crossrefs

Cf. A343251, A000351 (positions of records, greedy inverse).

Programs

  • Haskell
    a112765 n = fives n 0 where
       fives n e | r > 0     = e
                 | otherwise = fives n' (e + 1) where (n',r) = divMod n 5
    -- Reinhard Zumkeller, Apr 08 2011
    
  • Maple
    A112765 := proc(n)
        padic[ordp](n,5) ;
    end proc: # R. J. Mathar, Jul 12 2016
  • Mathematica
    a[n_] := IntegerExponent[n, 5]; Array[a, 105] (* Jean-François Alcover, Jan 25 2018 *)
  • PARI
    A112765(n)=valuation(n,5); /* Joerg Arndt, Apr 08 2011 */
    
  • Python
    def a(n):
        k = 0
        while n > 0 and n%5 == 0: n //= 5; k += 1
        return k
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Aug 06 2021

Formula

Totally additive with a(p) = 1 if p = 5, 0 otherwise.
From Hieronymus Fischer, Jun 08 2012: (Start)
With m = floor(log_5(n)), frac(x) = x-floor(x):
a(n) = Sum_{j=1..m} (1 - ceiling(frac(n/5^j))).
a(n) = m + Sum_{j=1..m} (floor(-frac(n/5^j))).
a(n) = A027868(n) - A027868(n-1).
G.f.: Sum_{j>0} x^5^j/(1-x^5^j). (End)
a(5n) = A055457(n). - R. J. Mathar, Jul 17 2012
Asymptotic mean: lim_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 1/4. - Amiram Eldar, Feb 14 2021
a(n) = 5*Sum_{j=1..floor(log(n)/log(5))} frac(binomial(n, 5^j)*5^(j-1)/n). - Dario T. de Castro, Jul 10 2022

A054899 a(n) = Sum_{k>0} floor(n/10^k).

Original entry on oeis.org

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

Views

Author

Henry Bottomley, May 23 2000

Keywords

Comments

The old definition of this sequence was "Highest power of 10 dividing n!", but that is wrong (see A027868). For example, the highest power of 10 dividing 5!=120 is 1; however, a(5)=0. - Hieronymus Fischer, Jun 18 2007
Highest power of 10 dividing the quotient of multifactorials Product_{k>=1} M(10^k, 10^k*floor(n/10^k)) /( Product_{k>=1} M(10^(k-1), 10^(k-1) * floor(n/10^k)) ) where M(r,s) is the r-multifactorial (r>=1) of s which is defined by M(r,s) = s*M(r,s-r) for s > 0, M(r,s) = 1 for s <= 0. This is because that quotient of multifactorials evaluates to the product 10^floor(n/10)*10^floor(n/100)*... - Hieronymus Fischer, Jun 14 2007
Partial sums of A122840. - Hieronymus Fischer, Jun 06 2012
Called the "terminating nines function" by Kennedy et al. (1989). a(n) is the number of terminating nines which occur up to n but not including n. - Amiram Eldar, Sep 06 2024

Examples

			          a(11) = 1
         a(111) = 12.
        a(1111) = 123.
       a(11111) = 1234.
      a(111111) = 12345.
     a(1111111) = 123456.
    a(11111111) = 1234567.
   a(111111111) = 12345678.
  a(1111111111) = 123456789.
		

Crossrefs

Cf. A011371 and A054861 for analogs involving powers of 2 and 3.
Different from the highest power of 10 dividing n! (see A027868 for reference).

Programs

  • Magma
    m:=10;
    function a(n) // a = A054899, m = 10
      if n eq 0 then return 0;
      else return a(Floor(n/m)) + Floor(n/m);
      end if; end function;
    [a(n): n in [0..103]]; // G. C. Greubel, Apr 28 2023
    
  • Mathematica
    Table[t=0; p=10; While[s=Floor[n/p]; t=t+s; s>0, p*=10]; t, {n,0,100}]
  • PARI
    a(n)=my(s);while(n\=10,s+=n);s \\ Charles R Greathouse IV, Jul 19 2011
    
  • SageMath
    m=10 # a = A054899
    def a(n): return 0 if (n==0) else a(n//m) + (n//m)
    [a(n) for n in range(104)] # G. C. Greubel, Apr 28 2023

Formula

a(n) = floor(n/10) + floor(n/100) + floor(n/1000) + ...
a(n) = (n - A007953(n))/9.
From Hieronymus Fischer, Jun 14 2007, Jun 25 2007, and Aug 13 2007: (Start)
a(n) = Sum_{k>0} floor(n/10^k).
a(n) = Sum_{k=10..n} Sum_{j|k, j>=10} ( floor(log_10(j)) -floor(log_10(j-1)) ).
G.f.: g(x) = ( Sum_{k>0} x^(10^k)/(1-x^(10^k)) )/(1-x).
G.f. expressed in terms of Lambert series:
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 10, 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_10(j)) - floor(log_10(j-1)) ).
a(n) = Sum_{k=0..floor(log_10(n))} ds_10(floor(n/10^k))*10^k - n where ds_10(x) = digital sum of x in base 10.
a(n) = Sum_{k=0..floor(log_10(n))} A007953(floor(n/10^k))*10^k - n.
Recurrence:
a(n) = floor(n/10) + a(floor(n/10)).
a(10*n) = n + a(n).
a(n*10^m) = n*(10^m-1)/9 + a(n).
a(k*10^m) = k*(10^m-1)/9, for 0 <= k < 10, m >= 0.
Asymptotic behavior:
a(n) = n/9 + O(log(n)),
a(n+1) - a(n) = O(log(n)), which follows from the inequalities below.
a(n) <= (n - 1)/9; equality holds for powers of 10.
a(n) >= n/9 - 1 - floor(log_10(n)); equality holds for n=10^m-1, m>0.
lim inf (n/9 - a(n)) = 1/9, for n --> oo.
lim sup (n/9 - log_10(n) - a(n)) = 0, for n --> oo.
lim sup (a(n+1) - a(n) - log_10(n)) = 0, for n --> oo. (End)

Extensions

An incorrect g.f. was deleted by N. J. A. Sloane, Sep 13 2009
Examples added by Hieronymus Fischer, Jun 06 2012

A196564 Number of odd digits in decimal representation of n.

Original entry on oeis.org

0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 1, 0, 1, 0, 1
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 04 2011

Keywords

Crossrefs

Programs

  • Haskell
    a196564 n = length [d | d <- show n, d `elem` "13579"]
    -- Reinhard Zumkeller, Feb 22 2012, Oct 04 2011
    
  • Maple
    A196564 := proc(n)
            if n =0 then
                    0;
            else
                    convert(n,base,10) ;
                    add(d mod 2,d=%) ;
            end if:
    end proc: # R. J. Mathar, Jul 13 2012
  • Mathematica
    Table[Total[Mod[IntegerDigits[n],2]],{n,0,100}] (* Zak Seidov, Oct 13 2015 *)
  • PARI
    a(n) = #select(x->x%2, digits(n)); \\ Michel Marcus, Oct 14 2015
    
  • Python
    def a(n): return sum(1 for d in str(n) if d in "13579")
    print([a(n) for n in range(100)]) # Michael S. Branicky, May 15 2022

Formula

a(n) = A055642(n) - A196563(n);
a(A014263(n)) = 0; a(A007957(n)) > 0.
From Hieronymus Fischer, May 30 2012: (Start)
a(n) = Sum_{j=0..m} (floor(n/(2*10^j) + (1/2)) - floor(n/(2*10^j))), where m=floor(log_10(n)).
a(10*n+k) = a(n) + a(k), 0<=k<10, n>=0.
a(n) = a(floor(n/10)) + a(n mod 10), n>=0.
a(n) = Sum_{j=0..m} a(floor(n/10^j) mod 10), n>=0.
a(A014261(n)) = floor(log_5(4*n+1)), n>0.
G.f.: g(x) = (1/(1-x))*Sum_{j>=0} x^10^j/(1+x^10^j). (End)

A196563 Number of even digits in decimal representation of n.

Original entry on oeis.org

1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 2, 1, 2, 1
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 04 2011

Keywords

Crossrefs

Programs

  • Haskell
    a196563 n = length [d | d <- show n, d `elem` "02468"]
    -- Reinhard Zumkeller, Feb 22 2012, Oct 04 2011
    
  • Maple
    A196563 := proc(n)
            if n =0 then
                    1;
            else
                    convert(n,base,10) ;
                    add(1-(d mod 2),d=%) ;
            end if:
    end proc: # R. J. Mathar, Jul 13 2012
  • Mathematica
    Table[Count[Mod[IntegerDigits[n],2],0][n],{n,0,100}] (* Zak Seidov, Oct 13 2015 *)
    Table[Count[IntegerDigits[n],?EvenQ],{n,0,120}] (* _Harvey P. Dale, Feb 22 2020 *)
  • PARI
    a(n) = #select(x->(!(x%2)), if (n, digits(n), [0])); \\ Michel Marcus, Oct 14 2015
    
  • Python
    def a(n): return sum(1 for d in str(n) if d in "02468")
    print([a(n) for n in range(100)]) # Michael S. Branicky, May 15 2022

Formula

a(n) = A055642(n) - A196564(n);
a(A014261(n)) = 0; a(A007928(n)) > 0.
From Hieronymus Fischer, May 30 2012: (Start)
a(n) = Sum_{j=0..m} (1 + floor(n/(2*10^j)) - floor(n/(2*10^j) + (1/2))), where m=floor(log_10(n)).
a(10*n+k) = a(n) + a(k), 0<=k<10, n>=1.
a(n) = a(floor(n/10))+a(n mod 10), n>=10.
a(n) = Sum_{j=0..m} a(floor(n/10^j) mod 10), n>=0.
a(A014263(n)) = 1 + floor(log_5(n-1)), n>1.
G.f.: g(x) = 1 + (1/(1-x))*Sum_{j>=0} x^(2*10^j)/(1+x^10^j). (End)

A054861 Greatest k such that 3^k divides n!.

Original entry on oeis.org

0, 0, 0, 1, 1, 1, 2, 2, 2, 4, 4, 4, 5, 5, 5, 6, 6, 6, 8, 8, 8, 9, 9, 9, 10, 10, 10, 13, 13, 13, 14, 14, 14, 15, 15, 15, 17, 17, 17, 18, 18, 18, 19, 19, 19, 21, 21, 21, 22, 22, 22, 23, 23, 23, 26, 26, 26, 27, 27, 27, 28, 28, 28, 30, 30, 30, 31, 31, 31, 32, 32, 32, 34, 34, 34, 35, 35
Offset: 0

Views

Author

Henry Bottomley, May 22 2000

Keywords

Comments

Also the number of trailing zeros in the base-3 representation of n!. - Hieronymus Fischer, Jun 18 2007
Also the highest power of 6 dividing n!. - Hieronymus Fischer, Aug 14 2007
A column of A090622. - Alois P. Heinz, Oct 05 2012
The 'missing' values are listed in A096346. - Stanislav Sykora, Jul 16 2014

Examples

			a(100) = 48.
a(10^3) = 498.
a(10^4) = 4996.
a(10^5) = 49995.
a(10^6) = 499993.
a(10^7) = 4999994.
a(10^8) = 49999990.
a(10^9) = 499999993.
		

Crossrefs

Cf. A011371 (for analog involving powers of 2). See also A027868.
Cf. A004128 (for a(3n)).

Programs

Formula

a(n) = floor(n/3) + floor(n/9) + floor(n/27) + floor(n/81) + ... .
a(n) = (n - A053735(n))/2.
a(n+1) = Sum_{k=1..n} A007949(k). - Benoit Cloitre, Mar 24 2002
From Hieronymus Fischer, Jun 18, Jun 25 and Aug 14 2007: (Start)
G.f.: (1/(1-x))*Sum_{k>0} x^(3^k)/(1-x^(3^k)).
a(n) = Sum_{k=3..n} Sum_{j>=3, j|k} (floor(log_3(j)) - floor(log_3(j-1))).
G.f.: 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 3, otherwise b(k)=0.
G.f.: (1/(1-x))*Sum_{k>0} c(k)*x^k, where c(k) = Sum_{j>1, j|k} (floor(log_3(j)) - floor(log_3(j-1))).
Recurrence:
a(n) = floor(n/3) + a(floor(n/3));
a(3*n) = n + a(n);
a(n*3^m) = n*(3^m-1)/2 + a(n).
a(k*3^m) = k*(3^m-1)/2, for 0 <= k < 3, m >= 0.
Asymptotic behavior:
a(n) = n/2 + O(log(n)),
a(n+1) - a(n) = O(log(n)); this follows from the inequalities below.
a(n) <= (n-1)/2; equality holds for powers of 3.
a(n) >= (n-2)/2 - floor(log_3(n)); equality holds for n = 3^m - 1, m > 0.
lim inf (n/2 - a(n)) = 1/2 for n->oo.
lim sup (n/2 - log_3(n) - a(n)) = 0 for n->oo.
lim sup (a(n+1) - a(n) - log_3(n)) = 0 for n->oo. (End)
a(n) = A007949(n!). - R. J. Mathar, Sep 03 2016
From R. J. Mathar, Jul 08 2021: (Start)
a(n) = A122841(n!).
Partial sums of A007949. (End)
a(n) = A007949(A000142(n)). - David A. Corneth, Nov 02 2023

Extensions

Examples added by Hieronymus Fischer, Jun 06 2012
New name by David A. Corneth, Nov 02 2023

A122840 a(n) is the number of 0's at the end of n when n is written in base 10.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0
Offset: 1

Views

Author

Reinhard Zumkeller, Sep 13 2006

Keywords

Comments

Greatest k such that 10^k divides n.
a(n) = the number of digits in n - A160093(n).
a(A005117(n)) <= 1. - Reinhard Zumkeller, Mar 30 2010
See A054899 for the partial sums. - Hieronymus Fischer, Jun 08 2012
From Amiram Eldar, Mar 10 2021: (Start)
The asymptotic density of the occurrences of k is 9/10^(k+1).
The asymptotic mean of this sequence is 1/9. (End)

Examples

			a(160) = 1 because there is 1 zero at the end of 160 when 160 is written in base 10.
		

Crossrefs

A007814 is the base 2 equivalent of this sequence.

Programs

  • Haskell
    a122840 n = if n < 10 then 0 ^ n else 0 ^ d * (a122840 n' + 1)
                where (n', d) = divMod n 10
    -- Reinhard Zumkeller, Mar 09 2013
    
  • Mathematica
    a[n_] := IntegerExponent[n, 10]; Array[a, 100] (* Amiram Eldar, Mar 10 2021 *)
  • PARI
    a(n)=valuation(n,10) \\ Charles R Greathouse IV, Feb 26 2014
    
  • Python
    def a(n): return len(str(n)) - len(str(int(str(n)[::-1]))) # Indranil Ghosh, Jun 09 2017
    
  • Python
    def A122840(n): return len(s:=str(n))-len(s.rstrip('0')) # Chai Wah Wu, Jul 06 2022
    
  • Python
    A122840 = lambda n: sympy.multiplicity(10,n) # M. F. Hasler, Apr 05 2024

Formula

a(n) = A160094(n) - 1.
From Hieronymus Fischer, Jun 08 2012: (Start)
With m = floor(log_10(n)), frac(x) = x-floor(x):
a(n) = Sum_{j=1..m} (1 - ceiling(frac(n/10^j))).
a(n) = m + Sum_{j=1..m} (floor(-frac(n/10^j))).
a(n) = A054899(n) - A054899(n-1).
G.f.: g(x) = Sum_{j>0} x^10^j/(1-x^10^j). (End)
a(n) = min(A007814(n), A112765(n)). - Jianing Song, Jul 23 2022

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

A053824 Sum of digits of (n written in base 5).

Original entry on oeis.org

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

Views

Author

Henry Bottomley, Mar 28 2000

Keywords

Comments

Also the fixed point of the morphism 0->{0,1,2,3,4}, 1->{1,2,3,4,5}, 2->{2,3,4,5,6}, etc. - Robert G. Wilson v, Jul 27 2006

Examples

			a(20) = 4 + 0 = 4 because 20 is written as 40 in base 5.
From _Omar E. Pol_, Feb 21 2010: (Start)
It appears that this can be written as a triangle:
  0,
  1,2,3,4,
  1,2,3,4,5,2,3,4,5,6,3,4,5,6,7,4,5,6,7,8,
  1,2,3,4,5,2,3,4,5,6,3,4,5,6,7,4,5,6,7,8,5,6,7,8,9,2,3,4,5,6,3,4,5,6,7,4,5,...
See the conjecture in the entry A000120. (End)
		

Crossrefs

Sum of digits of n written in bases 2-16: A000120, A053735, A053737, this sequence, A053827, A053828, A053829, A053830, A007953, A053831, A053832, A053833, A053834, A053835, A053836.
Cf. A173525. - Omar E. Pol, Feb 21 2010
Cf. A173670 (last nonzero decimal digit of (10^n)!). - Washington Bomfim, Jan 01 2011

Programs

  • Haskell
    a053824 0 = 0
    a053824 x = a053824 x' + d  where (x', d) = divMod x 5
    -- Reinhard Zumkeller, Jan 31 2014
    
  • Magma
    [&+Intseq(n, 5):n in [0..100]]; // Marius A. Burtea, Aug 24 2019
  • Mathematica
    Table[Plus @@ IntegerDigits[n, 5], {n, 0, 100}] (* or *)
    Nest[Flatten[ #1 /. a_Integer -> Table[a + i, {i, 0, 4}]] &, {0}, 4] (* Robert G. Wilson v, Jul 27 2006 *)
    f[n_] := n - 4 Sum[Floor[n/5^k], {k, n}]; Array[f, 103, 0]
  • PARI
    a(n)=if(n<1,0,if(n%5,a(n-1)+1,a(n/5)))
    
  • PARI
    a(n) = sumdigits(n, 5); \\ Michel Marcus, Aug 24 2019
    

Formula

From Benoit Cloitre, Dec 19 2002: (Start)
a(0) = 0, a(5n+i) = a(n) + i for 0 <= i <= 4;
a(n) = n - 4*Sum_{k>=1} floor(n/5^k) = n - 4*A027868(n). (End)
a(n) = A138530(n,5) for n > 4. - Reinhard Zumkeller, Mar 26 2008
If i >= 2, a(2^i) mod 4 = 0. - Washington Bomfim, Jan 01 2011
a(n) = Sum_{k>=0} A031235(n,k). - Philippe Deléham, Oct 21 2011
a(0) = 0; a(n) = a(n - 5^floor(log_5(n))) + 1. - Ilya Gutkovskiy, Aug 23 2019
Sum_{n>=1} a(n)/(n*(n+1)) = 5*log(5)/4 (Shallit, 1984). - Amiram Eldar, Jun 03 2021

A115627 Irregular triangle read by rows: T(n,k) = multiplicity of prime(k) as a divisor of n!.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

The factorization of n! is n! = 2^T(n,1)*3^T(n,2)*...*p_(pi(n))^T(n,pi(n)) where p_k = k-th prime, pi(n) = A000720(n).
Nonzero terms of A085604; T(n,k) = A085604(n,k), k = 1..A000720(n). - Reinhard Zumkeller, Nov 01 2013
For n=2, 3, 4 and 5, all terms of the n-th row are odd. Are there other such rows? - Michel Marcus, Nov 11 2018
From Gus Wiseman, May 15 2019: (Start)
Differences between successive rows are A067255, so row n is the sum of the first n row-vectors of A067255 (padded with zeros on the right so that all n row-vectors have length A000720(n)). For example, the first 10 rows of A067255 are
{}
1
0 1
2 0
0 0 1
1 1 0
0 0 0 1
3 0 0 0
0 2 0 0
1 0 1 0
with column sums (8,4,2,1), which is row 10.
(End)
For all prime p > 7, 3*p > 2*nextprime(p), so for any n > 21 there will always be a prime p dividing n! with exponent 2 and there are no further rows with all entries odd. - Charlie Neder, Jun 03 2019

Examples

			From _Gus Wiseman_, May 09 2019: (Start)
Triangle begins:
   1
   1  1
   3  1
   3  1  1
   4  2  1
   4  2  1  1
   7  2  1  1
   7  4  1  1
   8  4  2  1
   8  4  2  1  1
  10  5  2  1  1
  10  5  2  1  1  1
  11  5  2  2  1  1
  11  6  3  2  1  1
  15  6  3  2  1  1
  15  6  3  2  1  1  1
  16  8  3  2  1  1  1
  16  8  3  2  1  1  1  1
  18  8  4  2  1  1  1  1
(End)
m such that 5^m||101!: floor(log(101)/log(5)) = 2 terms. floor(101/5) = 20. floor(20/5) = 4. So m = u_1 + u_2 = 20 + 4 = 24. - _David A. Corneth_, Jun 22 2014
		

Crossrefs

Row lengths are A000720.
Row-sums are A022559.
Row-products are A135291.
Row maxima are A011371.

Programs

  • Haskell
    a115627 n k = a115627_tabf !! (n-2) !! (k-1)
    a115627_row = map a100995 . a141809_row . a000142
    a115627_tabf = map a115627_row [2..]
    -- Reinhard Zumkeller, Nov 01 2013
    
  • Maple
    A115627 := proc(n,k) local d,p; p := ithprime(k) ; n-add(d,d=convert(n,base,p)) ; %/(p-1) ; end proc: # R. J. Mathar, Oct 29 2010
  • Mathematica
    Flatten[Table[Transpose[FactorInteger[n!]][[2]], {n, 2, 20}]] (* T. D. Noe, Apr 10 2012 *)
    T[n_, k_] := Module[{p, jm}, p = Prime[k]; jm = Floor[Log[p, n]]; Sum[Floor[n/p^j], {j, 1, jm}]]; Table[Table[T[n, k], {k, 1, PrimePi[n]}], {n, 2, 20}] // Flatten (* Jean-François Alcover, Feb 23 2015 *)
  • PARI
    a(n)=my(i=2);while(n-primepi(i)>1,n-=primepi(i);i++);p=prime(n-1);sum(j=1,log(i)\log(p),i\=p) \\ David A. Corneth, Jun 21 2014

Formula

T(n,k) = Sum_{i=1..inf} floor(n/(p_k)^i). (Although stated as an infinite sum, only finitely many terms are nonzero.)
T(n,k) = Sum_{i=1..floor(log(n)/log(p_k))} floor(u_i) where u_0 = n and u_(i+1) = floor((u_i)/p_k). - David A. Corneth, Jun 22 2014
Showing 1-10 of 72 results. Next