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

A169655 Numbers k such that 2^k is in A054861.

Original entry on oeis.org

0, 1, 2, 3, 5, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 21, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 37, 41, 42, 43, 45, 46, 47, 49, 53, 54, 55, 56, 58, 59, 60, 62, 64, 65, 67, 69, 70, 71, 72, 73, 74, 75, 76, 78, 79, 82, 84, 85, 87, 88, 89, 91, 93
Offset: 1

Views

Author

Vladimir Shevelev, Apr 05 2010

Keywords

Comments

For a prime p, we call a number p-compact if the exponent of p in the factorization of the number is a power of two. However, if m=k!, then not all exponents of p of the form 2^t are possible. The sequence lists numbers t in possible exponents of the form 2^t of 3 in 3-compact factorials k!The question of description of the p-compact factorials is interesting since there exists only finite set of factorials compact over both 2 and an arbitrary fixed odd prime (cf. A177436). On the other hand, there exist infinitely many 2-compact factorials. However, up to now it is unknown, whether exist infinitely many p-compact factorials for a fixed odd prime p. It is expected that the answer to be in affirmative.

Crossrefs

Programs

  • Mathematica
    A054861 := (Plus @@ Floor[#/3^Range[Length[IntegerDigits[#, 3]] - 1]] &);DeleteCases[Table[n - n Sign[2^n - A054861[2^(n + 1) + NestWhile[# + 1 &, 1, 2^n - A054861[2^(n + 1) + #] >= 0 &]  - 1]],{n, 1, 125}], 0] (* Peter J. C. Moses, Apr 10 2012 *)

Extensions

More terms given by Peter J. C. Moses, Apr 07 2012

A319316 Numbers k such that A090616(k) < A054861(k).

Original entry on oeis.org

3, 9, 15, 27, 28, 29, 30, 31, 39, 45, 54, 55, 57, 63, 81, 82, 83, 84, 85, 87, 90, 91, 93, 94, 95, 99, 108, 109, 110, 111, 117, 118, 119, 123, 126, 127, 135, 162, 163, 165, 171, 174, 175, 183, 189, 190, 191, 207, 219, 243, 244, 245, 246, 247, 248, 249, 250, 251
Offset: 1

Views

Author

Jianing Song, Sep 17 2018

Keywords

Comments

Numbers k such that the highest power of 12 dividing n! is determined by the highest power of 4 dividing n!.
Note that A054861 and A090616 are both asymptotic to a(n) = n/2 + O(log(n)), nevertheless, it seems that the number of k such that A090616(k) is bigger predominates. Conjecture: the ratio of k <= N such that A090616(k) > A054861(k) tends to 1 as N tends to infinity, while the ratio of k <= N such that A090616(k) < A054861(k) and A090616(k) = A054861(k) both tend to 0.
Number of k in range [0, N] such that A090616(k) =, < or > A054861(k):
..N....A090616(k) = A054861(k)...A090616(k) < A054861(k)...A090616(k) > A054861(k)
10^2...............38........................26........................37
10^3..............344.......................228.......................429
10^4.............2703......................2227......................5071
10^5............23003.....................19892.....................57106
10^6...........203478....................185152....................611371
10^7..........1762288...................1726062...................6511651

Examples

			The highest power of 3 dividing 9! is 3^4, while the highest power of 4 dividing 9! is 4^3, so 9 is a term, and the highest power of 12 dividing 9! is 12^3.
The highest power of 3 dividing 15! is 3^6, while the highest power of 4 dividing 15! is 4^5, so 15 is a term, and the highest power of 12 dividing 15! is 12^5.
		

Crossrefs

Cf. A217445 (k such that A090616(k) = A054861(k)), A319317 (k such that A090616(k) > A054861(k)).

Programs

  • PARI
    isA319316(n)=(n-vecsum(digits(n, 2)))\2<(n-vecsum(digits(n, 3)))\2

A319317 Numbers k such that A090616(k) > A054861(k).

Original entry on oeis.org

8, 16, 17, 20, 24, 25, 26, 32, 34, 35, 40, 41, 44, 48, 49, 50, 52, 53, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79, 80, 96, 97, 98, 104, 106, 107, 116, 128, 129, 130, 131, 132, 133, 134, 136, 137, 140, 142, 143, 144, 145, 146, 148, 149, 150, 151
Offset: 1

Views

Author

Jianing Song, Sep 17 2018

Keywords

Comments

Numbers k such that the highest power of 12 dividing n! is determined by the highest power of 3 dividing n!.
Note that A054861 and A090616 are both asymptotic to a(n) = n/2 + O(log(n)), nevertheless, it seems that the number of k such that A090616(k) is bigger predominates. Conjecture: the ratio of k <= N such that A090616(k) >A054861(k) tends to 1 as N tends to infinity, while the ratio of k <= N such thatA090616(k) < A054861(k) and A090616(k) = A054861(k) both tend to 0.
Number of k in range [0, N] such that A090616(k) =, < or > A054861(k):
N A090616(k) = A054861(k) A090616(k) < A054861(k) A090616(k) > A054861(k)
10^2 38 26 37
10^3 344 228 429
10^4 2703 2227 5071
10^5 23003 19892 57106
10^6 203478 185152 611371
10^7 1762288 1726062 6511651

Examples

			The highest power of 3 dividing 8! is 3^2, while the highest power of 4 dividing 8! is 4^3, so 8 is a term, and the highest power of 12 dividing 8! is 12^2.
The highest power of 3 dividing 16! is 3^6, while the highest power of 4 dividing 16! is 4^7, so 16 is a term, and the highest power of 12 dividing 16! is 12^6.
		

Crossrefs

Cf. A217445 (k such that A090616(k) = A054861(k)), A319316 (k such that A090616(k) < A054861(k)).

Programs

  • PARI
    isA319317(n)=(n-vecsum(digits(n, 2)))\2>(n-vecsum(digits(n, 3)))\2

A007949 Greatest k such that 3^k divides n. Or, 3-adic valuation of n.

Original entry on oeis.org

0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 3, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 3, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 4, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1
Offset: 1

Views

Author

R. Muller

Keywords

Comments

Obeys the general recurrences for p-adic valuation discussed in A214411. - Redjan Shabani, Jul 17 2012
Lexicographically earliest cubefree sequence, which also (conjecturally) appears in the construction of the lexicographically earliest cubefree {0,1}-sequence A282317, cf. Example section of A286940. - M. F. Hasler, May 21 2017
The sequence is invariant under the "lower trim" operator: remove all zeros, and subtract one from each remaining term. - Franklin T. Adams-Watters, May 25 2017

References

  • F. Q. Gouvea, p-Adic Numbers, Springer-Verlag, 1993; see p. 23.

Crossrefs

Partial sums give A054861.
One less than A051064.

Programs

  • Haskell
    a007949 n = if m > 0 then 0 else 1 + a007949 n'
                where (n', m) = divMod n 3
    -- Reinhard Zumkeller, Jun 23 2013, May 14 2011
    
  • MATLAB
    % Input:
    %  n: an integer
    % Output:
    %  m: max power of 3 such that 3^m divides n
    %  M: 1-by-K matrix where M(i) is the max power of 3 such that 3^M(i) divides n
    function [m,M] = Omega3(n)
      M = NaN*zeros(1,n);
      M(1)=0; M(2)=0; M(3)=0;
        for k=4:n
          if M(k-3)~=0
            M(k)=M(k-k/3)+1;
          else
            M(k)=0;
          end
        end
        m=M(end);
    end
    % Redjan Shabani, Jul 17 2012
    
  • Magma
    [Valuation(n, 3): n in [1..110]]; // Bruno Berselli, Aug 05 2013
    
  • Maple
    A007949 := proc(n) option remember; if n mod 3 > 0 then 0 else procname(n/3)+1; fi; end;
    # alternative by R. J. Mathar, Mar 29 2017
    A007949 := proc(n)
        padic[ordp](n,3) ;
    end proc:
  • Mathematica
    p=3; Array[ If[ Mod[ #, p ]==0, Select[ FactorInteger[ # ], Function[ q, q[ [ 1 ] ]==p ], 1 ][ [ 1, 2 ] ], 0 ]&, 81 ]
    Nest[ Function[ l, {Flatten[(l /. {0 -> {0, 0, 1}, 1 -> {0, 0, 2}, 2 -> {0, 0, 3}, 3 -> {0, 0, 4}}) ]}], {0}, 5] (* Robert G. Wilson v, Mar 03 2005 *)
    IntegerExponent[Range[200], 3] (* Zak Seidov, Apr 15 2010 *)
    Table[If[Mod[n, 3] > 0, 0, 1 + b[n/3]], {n, 200}] (* Zak Seidov, Apr 15 2010 *)
  • PARI
    a(n)=valuation(n,3)
    
  • Python
    def a(n):
        k = 0
        while n > 0 and n%3 == 0: n //= 3; k += 1
        return k
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Aug 06 2021
  • Sage
    [valuation(n, 3) for n in (1..106)]  # Peter Luschny, Nov 16 2012
    
  • Scheme
    (define (A007949 n) (let loop ((n n) (k 0)) (cond ((not (zero? (modulo n 3))) k) (else (loop (/ n 3) (+ 1 k)))))) ;; Antti Karttunen, Oct 06 2017
    

Formula

a(n) = 0 if n != 0 (mod 3), otherwise a(n) = 1 + a(n/3). - Reinhard Zumkeller, Aug 12 2001, edited by M. F. Hasler, Aug 11 2015
From Ralf Stephan, Apr 12 2002: (Start)
a(n) = A051064(n) - 1.
G.f.: Sum_{k>=1} x^3^k/(1 - x^3^k). (End)
Fixed point of the morphism: 0 -> 001; 1 -> 002; 2 -> 003; 3 -> 004; 4 -> 005; etc.; starting from a(1) = 0. - Philippe Deléham, Mar 29 2004
a(n) mod 2 = 1 - A014578(n). - Reinhard Zumkeller, Oct 04 2008
Totally additive with a(p) = 1 if p = 3, 0 otherwise.
v_{m}(n) = Sum_{r>=1} (r/m^(r+1)) Sum_{j=1..m-1} Sum_{k=0..m^(r+1)-1} exp((2*k*Pi*i*(n+(m-j)*m^r)) / m^(r+1)). This formula is for the general case; for this specific one, set m=3. - A. Neves, Oct 04 2010
a(3n) = A051064(n), a(2n) = a(n), a(2n-1) = A253786(n). - Cyril Damamme, Aug 04 2015
a(3n) = a(n) + 1, a(pn) = a(n) for any other prime p != 3. - M. F. Hasler, Aug 11 2015
3^a(n) = A038500(n). - Antti Karttunen, Oct 09 2017
Asymptotic mean: lim_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 1/2. - Amiram Eldar, Jul 11 2020
a(n) = tau(n)/(tau(3*n) - tau(n)) - 1, where tau(n) = A000005(n). - Peter Bala, Jan 06 2021
a(n) = 3*Sum_{j=1..floor(log_3(n))} frac(binomial(n,3^j)*3^(j-1)/n). - Dario T. de Castro, Jul 10 2022
a(n) = A080342(gcd(n, 3^A080342(n))). - Alan Michael Gómez Calderón, Jul 28 2024

A011371 a(n) = n minus (number of 1's in binary expansion of n). Also highest power of 2 dividing n!.

Original entry on oeis.org

0, 0, 1, 1, 3, 3, 4, 4, 7, 7, 8, 8, 10, 10, 11, 11, 15, 15, 16, 16, 18, 18, 19, 19, 22, 22, 23, 23, 25, 25, 26, 26, 31, 31, 32, 32, 34, 34, 35, 35, 38, 38, 39, 39, 41, 41, 42, 42, 46, 46, 47, 47, 49, 49, 50, 50, 53, 53, 54, 54, 56, 56, 57, 57, 63, 63, 64, 64, 66, 66, 67, 67, 70
Offset: 0

Views

Author

Keywords

Comments

Terms of A005187 repeated. - Lekraj Beedassy, Jul 06 2004
This sequence shows why in binary 0 and 1 are the only two numbers n such that n equals the sum of its digits raised to the consecutive powers (equivalent to the base-10 sequence A032799). 1 raised to any consecutive power is still 1 and thus any sum of digits raised to consecutive powers for any n > 1 falls short of equaling the value of n by the n-th term of this sequence. - Alonso del Arte, Jul 27 2004
Also the number of trailing zeros in the base-2 representation of n!. - Hieronymus Fischer, Jun 18 2007
Partial sums of A007814. - Philippe Deléham, Jun 21 2012
If n is in A089633 and n > 0, then a(n) = n - floor(log_2(n+1)). - Douglas Latimer, Jul 25 2012
For n > 1, denominators of integral numerator polynomials L(n,x) for the Legendre polynomials with o.g.f. 1/sqrt(1 - t*x + x^2). - Tom Copeland, Feb 04 2016
The definition of this sequence explains why, for n > 1, the highest power of 2 dividing n! added to the number of 1's in the binary expansion of n is equal to n. This result is due to the French mathematician Adrien Legendre (1752-1833) [see the Honsberger reference]. - Bernard Schott, Apr 07 2017
a(n) is the total number of 2's in the prime factorizations over the first n positive integers. The expected number of 2's in the factorization of an integer n is 1 (as n->infinity). Generally, the expected number of p's (for a prime p) is 1/(p-1). - Geoffrey Critzer, Jun 05 2017

Examples

			a(3) = 1 because 3 in binary is 11 (two 1's) and 3 - 2 = 1.
a(4) = 3 because 4 in binary is 100 (one 1 and two 0's) and 4 - 1 = 3.
a(5) = 3 because 5 in binary is 101 (a zero between two 1's) and 5 - 2 = 3.
a(100) = 97.
a(10^3) = 994.
a(10^4) = 9995.
a(10^5) = 99994.
a(10^6) = 999993.
a(10^7) = 9999992.
a(10^8) = 99999988.
a(10^9) = 999999987.
G.f. = x^2 + x^3 + 3*x^4 + 3*x^5 + 4*x^6 + 4*x^7 + 7*x^8 + 7*x^9 + 8*x^10 + ...
		

References

  • K. Atanassov, On Some of Smarandache's Problems, section 7, on the 61st problem, page 42, American Research Press, 1999, 16-21.
  • G. Bachman, Introduction to p-Adic Numbers and Valuation Theory, Academic Press, 1964; see Lemma 3.1.
  • L. Comtet, Advanced Combinatorics, Reidel, 1974, p. 305.
  • H. Davenport, The Higher Arithmetic, 7th ed. 1999, Cambridge University Press, p. 216, exercise 1.07.
  • R. Honsberger, Mathematical Gems II, Dolciani Mathematical Expositions, 1976, pp. 1-6.

Crossrefs

a(n) = Sum_{k=1..n} A007814(k), n >= 1, a(0) = 0.

Programs

  • Haskell
    a011371 n = n - a000120 n  -- Reinhard Zumkeller, Jan 24 2014
    
  • Magma
    [Valuation(Factorial(n), 2): n in [0..80]]; // Bruno Berselli, Aug 05 2013
    
  • Maple
    A011371(n) = RETURN(((2^(l))-1)+sum('(j*floor((n-(2^l)+2^j)/(2^(j+1))))','j'=1..l)); # after K. Atanassov. Here l is [ log2(n) ].
    A011371 := n -> n - add(i,i=convert(n,base,2)): # Peter Luschny, May 02 2009
    read("transforms") : A011371 := proc(n) n-wt(n) ; end proc: # R. J. Mathar, May 15 2013
  • Mathematica
    -1 + Length[ Last[ Split[ IntegerDigits[ 2(n!), 2 ] ] ] ], FoldList[ Plus, 0, Fold[ Flatten[ {#1, #2, #1} ]&, 0, Range[ 6 ] ] ]
    Table[IntegerExponent[n!, 2], {n, 0, 127}]
    Table[n - DigitCount[n, 2, 1], {n, 0, 127}]
    Table[t = 0; p = 2; While[s = Floor[n/p]; t = t + s; s > 0, p *= 2]; t, {n, 0, 100} ]
  • PARI
    {a(n) = if( n<0, 0, valuation(n!, 2))}; /* Michael Somos, Oct 24 2002 */
    
  • PARI
    {a(n) = if( n<0, 0, sum(k=1, n, n\2^k))}; /* Michael Somos, Oct 24 2002 */
    
  • PARI
    {a(n) = if( n<0, 0, n - subst( Pol( binary( n ) ), x, 1))}; /* Michael Somos, Aug 28 2007 */
    
  • PARI
    a(n)=sum(k=1,log(n+1)\log(2),n>>k) \\ Charles R Greathouse IV, Oct 03 2012
    
  • PARI
    a(n)=my(s);while(n>>=1,s+=n);s \\ Charles R Greathouse IV, Aug 09 2013
    
  • PARI
    a(n) = n - hammingweight(n); \\ Michel Marcus, Jun 05 2014
    
  • Python
    [n - bin(n)[2:].count("1") for n in range(101)] # Indranil Ghosh, Apr 09 2017
    
  • Python
    # 3.10+
    def A011371(n): return n-n.bit_count() # Chai Wah Wu, Jul 09 2022

Formula

a(n) = a(floor(n/2)) + floor(n/2) = floor(n/2) + floor(n/4) + floor(n/8) + floor(n/16) + ... - Henry Bottomley, Apr 24 2001
G.f.: A(x) = (1/(1 - x))*Sum_{k>=1} x^(2^k)/(1 - x^(2^k)). - Ralf Stephan, Apr 11 2002
a(n) = n - A000120(n). - Lekraj Beedassy, Sep 01 2003
a(n) = A005187(n) - n, n >= 0.
a(n) = A007814(A000142(n)). - Reinhard Zumkeller, Apr 09 2004
From Hieronymus Fischer, Jun 25 and Aug 13 2007: (Start)
a(n) = Sum_{k=2..n} Sum_{j|k, j >= 2} (floor(log_2(j)) - floor(log_2(j - 1))).
The g.f. can be expressed in terms of a Lambert series, in that 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 is a power of 2, otherwise b(k) = 0.
G.f.: g(x) = (1/(1-x))*Sum_{k>0} c(k)*x^k, where c(k) = Sum_{j>1, j|k} (floor(log_2(j)) - floor(log_2(j-1))).
Recurrence:
a(n) = floor(n/2) + a(floor(n/2));
a(2*n) = n + a(n);
a(n*2^m) = n*(2^m - 1) + a(n).
a(2^m) = 2^m - 1, m >= 0.
Asymptotic behavior:
a(n) = n + O(log(n)),
a(n+1) - a(n) = O(log(n)), which follows from the inequalities below.
a(n) <= n - 1; equality holds for powers of 2.
a(n) >= n - 1 - floor(log_2(n)); equality holds for n = 2^m - 1, m > 0.
lim inf (n - a(n)) = 1, for n->oo.
lim sup (n - log_2(n) - a(n)) = 0, for n->oo.
lim sup (a(n+1) - a(n) - log_2(n)) = 0, for n->oo. (End)
a(n) = Sum_{k >= 0} A030308(n, k)*A000225(k). - Philippe Deléham, Oct 16 2011
a(n) = Sum_{k=0..floor(log_2(n+1))} f^(k+1)(n), where f(n) = (n - (n mod 2))/2 and f^(k+1) is the (k+1)-th composition of f. - Joseph Wheat, Mar 01 2018
a(n) = Sum_{k=1..floor(n/2)} floor(log_2(n/k)). - Ammar Khatab, Feb 01 2025

Extensions

Examples added by Hieronymus Fischer, Jun 06 2012

A053735 Sum of digits of (n written in base 3).

Original entry on oeis.org

0, 1, 2, 1, 2, 3, 2, 3, 4, 1, 2, 3, 2, 3, 4, 3, 4, 5, 2, 3, 4, 3, 4, 5, 4, 5, 6, 1, 2, 3, 2, 3, 4, 3, 4, 5, 2, 3, 4, 3, 4, 5, 4, 5, 6, 3, 4, 5, 4, 5, 6, 5, 6, 7, 2, 3, 4, 3, 4, 5, 4, 5, 6, 3, 4, 5, 4, 5, 6, 5, 6, 7, 4, 5, 6, 5, 6, 7, 6, 7, 8, 1, 2, 3, 2, 3, 4, 3, 4, 5, 2, 3, 4, 3, 4, 5, 4, 5, 6, 3, 4, 5, 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}, 1->{1,2,3}, 2->{2,3,4}, etc. - Robert G. Wilson v, Jul 27 2006

Examples

			a(20) = 2 + 0 + 2 = 4 because 20 is written as 202 base 3.
From _Omar E. Pol_, Feb 20 2010: (Start)
This can be written as a triangle with row lengths A025192 (see the example in the entry A000120):
0,
1,2,
1,2,3,2,3,4,
1,2,3,2,3,4,3,4,5,2,3,4,3,4,5,4,5,6,
1,2,3,2,3,4,3,4,5,2,3,4,3,4,5,4,5,6,3,4,5,4,5,6,5,6,7,2,3,4,3,4,5,4,5,6,3,...
where the k-th row contains a(3^k+i) for 0<=i<2*3^k and converges to A173523 as k->infinity. (End) [Changed conjectures to statements in this entry. - _Franklin T. Adams-Watters_, Jul 02 2015]
G.f. = x + 2*x^2 + x^3 + 2*x^4 + 3*x^5 + 2*x^6 + 3*x^7 + 4*x^8 + x^9 + 2*x^10 + ...
		

Crossrefs

Cf. A065363, A007089, A173523. See A134451 for iterations.
Sum of digits of n written in bases 2-16: A000120, this sequence, A053737, A053824, A053827, A053828, A053829, A053830, A007953, A053831, A053832, A053833, A053834, A053835, A053836.
Related base-3 sequences: A006047, A230641, A230642, A230643, A230853, A230854, A230855, A230856, A230639, A230640, A010063 (trajectory of 1), A286585, A286632, A289813, A289814.

Programs

  • Haskell
    a053735 = sum . a030341_row
    -- Reinhard Zumkeller, Feb 21 2013, Feb 19 2012
    
  • MATLAB
    m=1; for u=0:104; sol(m)=sum(dec2base(u,3)-'0'); m=m+1;end
    sol; % Marius A. Burtea, Jan 17 2019
  • Magma
    [&+Intseq(n,3):n in [0..104]]; // Marius A. Burtea, Jan 17 2019
    
  • Maple
    seq(convert(convert(n,base,3),`+`),n=0..100); # Robert Israel, Jul 02 2015
  • Mathematica
    Table[Plus @@ IntegerDigits[n, 3], {n, 0, 100}] (* or *)
    Nest[Join[#, # + 1, # + 2] &, {0}, 6] (* Robert G. Wilson v, Jul 27 2006 and modified Jul 27 2014 *)
  • PARI
    {a(n) = if( n<1, 0, a(n\3) + n%3)}; /* Michael Somos, Mar 06 2004 */
    
  • PARI
    A053735(n)=sumdigits(n,3) \\ Requires version >= 2.7. Use sum(i=1,#n=digits(n,3),n[i]) in older versions. - M. F. Hasler, Mar 15 2016
    
  • Scheme
    (define (A053735 n) (let loop ((n n) (s 0)) (if (zero? n) s (let ((d (mod n 3))) (loop (/ (- n d) 3) (+ s d)))))) ;; For R6RS standard. Use modulo instead of mod in older Schemes like MIT/GNU Scheme. - Antti Karttunen, Jun 03 2017
    

Formula

From Benoit Cloitre, Dec 19 2002: (Start)
a(0) = 0, a(3n) = a(n), a(3n + 1) = a(n) + 1, a(3n + 2) = a(n) + 2.
a(n) = n - 2*Sum_{k>0} floor(n/3^k) = n - 2*A054861(n). (End)
a(n) = A062756(n) + 2*A081603(n). - Reinhard Zumkeller, Mar 23 2003
G.f.: (Sum_{k >= 0} (x^(3^k) + 2*x^(2*3^k))/(1 + x^(3^k) + x^(2*3^k)))/(1 - x). - Michael Somos, Mar 06 2004, corrected by Franklin T. Adams-Watters, Nov 03 2005
In general, the sum of digits of (n written in base b) has generating function (Sum_{k>=0} (Sum_{0 <= i < b} i*x^(i*b^k))/(Sum_{i=0..b-1} x^(i*b^k)))/(1-x). - Franklin T. Adams-Watters, Nov 03 2005
First differences of A094345. - Vladeta Jovovic, Nov 08 2005
a(A062318(n)) = n and a(m) < n for m < A062318(n). - Reinhard Zumkeller, Feb 26 2008
a(n) = A138530(n,3) for n > 2. - Reinhard Zumkeller, Mar 26 2008
a(n) <= 2*log_3(n+1). - Vladimir Shevelev, Jun 01 2011
a(n) = Sum_{k>=0} A030341(n, k). - Philippe Deléham, Oct 21 2011
G.f. satisfies G(x) = (x+2*x^2)/(1-x^3) + (1+x+x^2)*G(x^3), and has a natural boundary at |x|=1. - Robert Israel, Jul 02 2015
a(n) = A056239(A006047(n)). - Antti Karttunen, Jun 03 2017
a(n) = A000120(A289813(n)) + 2*A000120(A289814(n)). - Antti Karttunen, Jul 20 2017
a(0) = 0; a(n) = a(n - 3^floor(log_3(n))) + 1. - Ilya Gutkovskiy, Aug 23 2019
Sum_{n>=1} a(n)/(n*(n+1)) = 3*log(3)/2 (Shallit, 1984). - Amiram Eldar, Jun 03 2021

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

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

A004987 a(n) = (3^n/n!)*Product_{k=0..n-1} (3*k + 1). 3-central binomial coefficients.

Original entry on oeis.org

1, 3, 18, 126, 945, 7371, 58968, 480168, 3961386, 33011550, 277297020, 2344420260, 19927572210, 170150808870, 1458435504600, 12542545339560, 108179453553705, 935434098376155, 8107095519260010, 70403724246205350, 612512400941986545, 5337608065351597035, 46582761297613937760
Offset: 0

Views

Author

Joe Keane (jgk(AT)jgk.org)

Keywords

Comments

Diagonal of rational function R(x,y) = (1 - 9*x*y) / (1 - 2*x - 3*y + 3*y^2 + 9*x^2*y). - Gheorghe Coserea, Jul 01 2016
This is the k = 3 variant of the k-central binomial coefficients c(n,k) with g.f. (1 - k^2*x)^(-1/k), which yield the usual central binomial coefficients A001405 for k = 2. - M. F. Hasler, Nov 12 2024

Examples

			G.f.: 1 + 3*x + 18*x^2 + 126*x^3 + 945*x^4 + 7371*x^5 + 58968*x^6 + 480168*x^7 + ...
		

Crossrefs

Related to diagonal of rational functions: A268545-A268555.

Programs

  • GAP
    List([0..25], n-> 3^n*Product([0..n-1], k-> 3*k+1)/Factorial(n) ); # G. C. Greubel, Aug 22 2019
  • Magma
    [1] cat [3^n*&*[3*k+1: k in [0..n-1]]/Factorial(n): n in [1..25]]; // G. C. Greubel, Aug 22 2019
    
  • Maple
    a:= n-> (3^n/n!)*mul(3*k+1, k=0..n-1); seq(a(n), n=0..25); # G. C. Greubel, Aug 22 2019
  • Mathematica
    Table[(-9)^n Binomial[-1/3, n], {n, 0, 25}] (* Jean-François Alcover, Sep 28 2016, after Peter Luschny *)
  • PARI
    a(n) = prod(k=0, n-1, 3*k + 1)*3^n/n! \\ Michel Marcus, Jun 30 2013
    
  • PARI
    my(x='x, y='y);
    R = (1 - 9*x*y) / (1 - 2*x - 3*y + 3*y^2 + 9*x^2*y);
    diag(n, expr, var) = {
      my(a = vector(n));
      for (i = 1, #var, expr = taylor(expr, var[#var - i + 1], n));
      for (k = 1, n, a[k] = expr;
           for (i = 1, #var, a[k] = polcoeff(a[k], k-1)));
      return(a);
    };
    diag(20, R, [x,y])  \\ Gheorghe Coserea, Jul 01 2016
    
  • PARI
    Vec((1-9*x+O(x^25))^(-1/3)) \\ yields the same as:
    apply( {A004987(n)=prod(k=0, n-1, 9*k+3)\n!}, [0..24]) \\ M. F. Hasler, Nov 12 2024
    
  • Sage
    [9^n*rising_factorial(1/3, n)/factorial(n) for n in (0..25)] # G. C. Greubel, Aug 22 2019
    

Formula

G.f.: (1 - 9*x)^(-1/3).
a(n) = (3^n/n!)*A007559(n), n >= 1, a(0) := 1.
a(n) ~ Gamma(1/3)^-1*n^(-2/3)*3^(2*n)*{1 - 1/9*n^-1 + ...}.
Representation as n-th moment of a positive function on (0, 9): a(n) = Integral_{x=0..9} ( x^n*(1/(Pi*sqrt(3)*6*(x/9)^(2/3)*(1-x/9)^(1/3))) ), n >= 0. This function is the solution of the Hausdorff moment problem on (0, 9) with moments equal to a(n). As a consequence this representation is unique. - Karol A. Penson, Jan 30 2003
D-finite with recurrence: n*a(n) + 3*(2-3*n)*a(n-1)=0. - R. J. Mathar, Jun 07 2013
0 = a(n) * (81*a(n+1) - 15*a(n+2)) + a(n+1) * (-3*a(n+1) + a(n+2)) for all n in Z. - Michael Somos, Jan 27 2014
G.f. A(x)=:y satisfies 0 = y'' * y - 4 * y' * y'. - Michael Somos, Jan 27 2014
a(n) = (-9)^n*binomial(-1/3, n). - Peter Luschny, Mar 23 2014
E.g.f.: is the hypergeometric function of type 1F1, in Maple notation hypergeom([1/3], [1], 9*x). - Karol A. Penson, Dec 19 2015
Sum_{n>=0} 1/a(n) = (sqrt(3)*Pi + 3*(12 + log(3)))/32 = 1.3980385924595932... - Ilya Gutkovskiy, Jul 01 2016
Binomial transform of A216316. - Peter Bala, Jul 02 2023
From Peter Bala, Mar 31 2024: (Start)
a(n) = (9^n)*Sum_{k = 0..2*n} (-1)^k*binomial(-1/3, k)* binomial(-1/3, 2*n - k).
(9^n)*a(n) = Sum_{k = 0..2*n} (-1)^k*a(k)*a(2*n-k).
Sum_{k = 0..n} a(k)*a(n-k) = A004988(n).
Sum_{k = 0..2*n} a(k)*a(2*n-k) = 18^n/(2*n)! * Product_{k = 1..n} (6*k - 1)*(3*k - 2). (End)
G.f. A(x) satisfies A(x) = 1/A(-x*A(x)^3). - Seiichi Manyama, Jun 20 2025

Extensions

More terms from Ralf Stephan, Mar 13 2004
More terms from Benoit Cloitre, Jun 05 2004

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