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

A064780 Number of times n occurs in A000195.

Original entry on oeis.org

2, 5, 13, 34, 94, 255, 693, 1884, 5123, 13923, 37848, 102880, 279659, 760191, 2066413, 5617093, 15268842, 41505017, 112822331, 306682895, 833650539, 2266097112, 6159890600, 16744318683, 45515777208, 123724710091, 336318631173, 914208823690, 2485077232853
Offset: 0

Views

Author

Santi Spadaro, Oct 19 2001

Keywords

Crossrefs

Programs

  • Maple
    floorexp:= proc(n) local j,s,t;
      s:= 0;
      t:= 1;
      for j from 0 do
        s:= s+t;
        if j > n and t*n/(j+1-n) < 1 - frac(s) then
           return floor(s)
        fi;
        t:= t*n/(j+1);
      od
    end proc:
    B:= [0, seq(floorexp(i),i=1..101)]:
    B[2..-1] - B[1..-2]; # Robert Israel, Mar 03 2016
  • Mathematica
    lista = Table[Floor[Log[n]], {n, 10000000}]; Table[Length@Cases[lista, i], {i, 0, 15}] (* José María Grau Ribas, May 16 2013 *)
    f[n_] := Floor[ Exp[n + 1]] - Floor[ Exp[ n]]; f[0] = 2; Array[f, 26, 0] (* Robert G. Wilson v, Mar 15 2015 *)
  • PARI
    { default(realprecision, 100); for (n=0, 200, if (n, a=floor(exp(n + 1)) - floor(exp(n)), a=2); write("b064780.txt", n, " ", a) ) } \\ Harry J. Smith, Sep 25 2009

Formula

a(n) = floor(exp(n+1))-floor(exp(n)), n>0.
Limit_{n->oo} a(n+1)/a(n) = e. - Franz Vrabec, Nov 29 2014
e^(n+1)-e^n-1 < A248873(n) <= a(n) < e^(n+1)-e^n+1. - Danny Rorabaugh, Mar 13 2015

Extensions

More terms from Vladeta Jovovic, Oct 20 2001

A092755 Partial sums of A000195 (floor(log(n))).

Original entry on oeis.org

0, 0, 1, 2, 3, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100, 103, 106, 109, 112, 115, 118, 121, 124, 127, 130, 133, 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, 177, 181, 185
Offset: 1

Views

Author

Jorge Coveiro, Apr 13 2004

Keywords

Examples

			a(1) = floor(log(1)).
a(2) = a(1) + floor(log(2)).
a(3) = a(2) + floor(log(3)).
...
		

Crossrefs

A317389 a(0) = 0, a(1) = a(2) = 1; for n >= 3, a(n) = freq(a(g(n)),n)*freq(a(n-g(n)),n) where g = A000195 and freq(i, j) is the number of times i appears in the terms a(0) .. a(j-1).

Original entry on oeis.org

0, 1, 1, 4, 2, 2, 4, 4, 6, 6, 4, 4, 10, 10, 4, 4, 14, 14, 4, 4, 18, 81, 81, 9, 18, 18, 9, 27, 27, 18, 18, 18, 54, 54, 54, 27, 27, 27, 45, 45, 45, 27, 27, 27, 72, 72, 72, 27, 27, 27, 99, 99, 99, 27, 27, 6, 6, 26, 26, 8, 8, 4, 4, 4, 4, 26, 26, 26, 26, 12, 12, 12, 12, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 16, 16, 8, 8, 8, 8, 20, 20, 20
Offset: 0

Views

Author

Altug Alkan, Jul 27 2018

Keywords

Crossrefs

Cf. A317359.

Programs

  • Maple
    b:= proc() 0 end:
    a:= proc(n) option remember; local t;
          t:= `if`(n<3, n*(3-n)/2, b(a(ilog(n)))*b(a(n-ilog(n))));
          b(t):= b(t)+1; t
        end:
    seq(a(n), n=0..200);  # Alois P. Heinz, Jul 27 2018
  • Mathematica
    b[_] = 0;
    a[n_] := a[n] = Module[{t}, t = If[n<3, n(3-n)/2, b[a[Floor@Log[n]]] b[a[n - Floor@Log[n]]]]; b[t] = b[t]+1; t];
    a /@ Range[0, 200] (* Jean-François Alcover, Nov 27 2020, after Alois P. Heinz *)

A317442 a(1) = a(2) = 1; for n >= 3, a(n) = a(t(n)) + a(n-t(n)) where t = A000195.

Original entry on oeis.org

1, 1, 2, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 22, 23, 24, 24, 25, 26, 26, 27, 28, 28, 29, 30, 30, 31, 32, 32, 33, 34, 34, 35, 36, 37, 37, 38, 39, 40, 40, 41, 42, 43, 43, 44, 45, 46, 46, 47, 48, 49, 49, 50, 51, 52
Offset: 1

Views

Author

Altug Alkan, Jul 28 2018

Keywords

Comments

This sequence hits every positive integer.

Crossrefs

Programs

  • Mathematica
    Nest[Function[{a, n}, Append[a, a[[Floor@ Log@ n]] + a[[n - Floor@ Log@ n]] ] ] @@ {#, Length@ # + 1} &, {1, 1}, 74] (* Michael De Vlieger, Jul 30 2018 *)
  • PARI
    q=vector(100); for(n=1, 2, q[n]=1); for(n=3, #q, q[n]=q[floor(log(n))] + q[n-floor(log(n))]); q

Formula

a(n+1) - a(n) = 0 or 1 for all n >= 1.

A000523 a(n) = floor(log_2(n)).

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Or, n >= 0 appears 2^n times. - Jon Perry, Sep 21 2002
a(n) + 1 = number of bits in binary expansion of n.
Largest power of 2 dividing lcm(1..n): A007814(A003418(n)).
log_2(0) = -infinity.
Also Max_{k=1..n} Omega(k), where Omega(n) = A001222(n), number of prime factors with repetition; see A080613. - Reinhard Zumkeller, Feb 25 2003
From Paul Weisenhorn, Sep 29 2010, updated Aug 11 2020: (Start)
Arithmetic mean: m(1,(c+1)/c) = (2*c+1)/(2*c); harmonic mean: h(1,(c+1)/c) = 2*(c+1)/(2*c+1);
a(n) is the number of means to reach (n+1)/n from 2/1; with m for 0 and h for 1, the inverse binary expansion of n, without the leading 1, gives the sequence of means.
For example, n=20; inverse binary expansion without the leading 1: 0010 ---> m m h m or m(1, m(1, h(1, m(1, 2)))) = 21/20.
The 4 twofold means for n from 4 to 7:
m(1,m(1,2)) = m(1,3/2) = 5/4,
h(1,m(1,2)) = h(1,3/2) = 6/5,
m(1,h(1,2)) = m(1,4/3) = 7/6,
h(1,h(1,2)) = h(1,4/3) = 8/7. (End) [Edited by Petros Hadjicostas, Jul 23 2020]
As function of the absolute value, defines the minimal Euclidean function v on Z\{0}. A ring R is Euclidean if for some function v : R\{0}->N a division by nonzero b can be defined with remainder r satisfying either r=0 or v(r) < v(b). For the integers taking v(n)=|n| works, but v(n) = floor(log_2(|n|)) works as well; moreover it is the possibility with smallest possible values. For division by b>0 one can always choose |r| <= floor(b/2); this sequence satisfies a(1) = 0 and recursively a(n) = 1 + max(a(1), ..., a(floor(n/2))) for n > 1. - Marc A. A. van Leeuwen, Feb 16 2011
Maximum number of guesses required to find any k in a range of 1..n, with 'higher', 'lower' and 'correct' as answers. - Jon Perry, Nov 02 2013
Number of powers of 2 <= n. - Ralph-Joseph Tatt, Apr 23 2018
a(n) + 1 is the minimum number of pairwise disjoint subsets of an n-element set such that for each k from 1 to n there is a set with cardinality k which is the union of some of those subsets. - Wojciech Raszka, Apr 15 2019
Minimum height of an n-node binary tree. - Yuchun Ji, Mar 22 2021

Examples

			a(5)=2 because the binary expansion of 5 (=101) has three bits.
		

References

  • Rüdeger Baumann, Computer-Knobelei, LOG IN Heft 159 (2009), 74-77. - Paul Weisenhorn, Sep 29 2010
  • G. H. Hardy, Note on Dr. Vacca's series for gamma, Quart. J. Pure Appl. Math., Vol. 43 (1912), pp. 215-216.
  • Ernst Jacobsthal, Über die Eulersche konstante, Mathematisch-Naturwissenschaftliche Blätter, Vol. 3, No. 9 (1906), pp. 153-154.
  • Donald E. Knuth, The Art of Computer Programming, Vol. 1: Fundamental Algorithms, p. 400.
  • Donald E. Knuth, The Art of Computer Programming, vol. 4A, Combinatorial Algorithms, Section 7.1.3, Problem 41, p. 589. - From N. J. A. Sloane, Aug 03 2012

Crossrefs

Programs

  • Haskell
    a000523 1 = 0
    a000523 n = 1 + a000523 (div n 2)
    a000523_list = 0 : f [0] where
       f xs = ys ++ f ys where ys = map (+ 1) (xs ++ xs)
    -- Reinhard Zumkeller, Dec 31 2012, Feb 04 2012, Mar 18 2011
    
  • Magma
    [Ilog2(n) : n in [1..130] ];
    
  • Maple
    A000523 := proc(n)
        ilog2(n) ;
    end proc: # R. J. Mathar, Nov 28 2016
    seq(A000523(n), n=1..90);
  • Mathematica
    Floor[Log[2,Range[110]]] (* Harvey P. Dale, Jul 16 2012 *)
    a[ n_] := If[ n < 1, 0, BitLength[n] - 1]; (* Michael Somos, Jul 10 2018 *)
  • PARI
    {a(n) = floor(log(n) / log(2))} \\ Likely to yield incorrect results for many if not almost all n. Better use most recent code.
    
  • PARI
    {a(n) = if( n<1, 0, #binary(n) - 1)}; /* Michael Somos, May 28 2014 */
    
  • PARI
    a(n)=logint(n,2) \\ Charles R Greathouse IV, Sep 01 2015
    
  • PARI
    a(n)=exponent(n) \\ Charles R Greathouse IV, Nov 09 2017
    
  • Python
    def A000523(n):
        return len(bin(n))-3 # Chai Wah Wu, Jul 09 2020
    
  • Python
    def a(n): return n.bit_length() - 1
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Apr 18 2023

Formula

a(n) = A070939(n) - 1 for n >= 1.
a(n) = if n > 1, then a(floor(n / 2)) + 1; else 0. - Reinhard Zumkeller, Oct 29 2001
G.f.: (1/(1 - x)) * Sum_{k>=1} x^2^k. - Ralf Stephan, Apr 13 2002
a(n+1) = number of digits of n-th number with no 0 in ternary representation = A081604(A032924(n)); A107680(n) = A003462(a(n+1)). - Reinhard Zumkeller, May 20 2005
a(n) = A152487(n-1,0) = A152487(n,1). - Reinhard Zumkeller, Dec 06 2008
a(n) = k with 2^k <= n < 2^(k+1); a(n) = floor(log_2(n)). - Paul Weisenhorn, Sep 29 2010
a(n) = Max_{k=1..n} A240857(n,k). - Reinhard Zumkeller, Apr 14 2014
a(n) = A113473(n) - 1. - Filip Zaludek, Oct 29 2016
Sum_{n>=2} (-1)^n*a(n)/n = gamma = A001620 (Jacobsthal, 1906; Vacca, 1910). - Amiram Eldar, Jun 12 2021
a(n) = floor(Sum_{k=1..n-1} (n+1)^(n-2^k)) mod n. - Joseph M. Shunia, Jul 19 2024

Extensions

Error in 4th term, pointed out by Joe Keane (jgk(AT)jgk.org), has been corrected.
More terms from Michael Somos, Aug 02 2002

A029837 Binary order of n: log_2(n) rounded up to next integer.

Original entry on oeis.org

0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
Offset: 1

Views

Author

Keywords

Comments

Or, ceiling(log_2(n)).
Worst-case cost of binary search.
Equal to number of binary digits in n unless n is a power of 2 when it is one less.
Thus a(n) gives the length of the binary representation of n - 1 (n >= 2), which is also A070939(n - 1).
Let x(0) = n > 1 and x(k + 1) = x(k) - floor(x(k)/2), then a(n) is the smallest integer such that x(a(n)) = 1. - Benoit Cloitre, Aug 29 2002
Also number of division steps when going from n to 1 by process of adding 1 if odd, or dividing by 2 if even. - Cino Hilliard, Mar 25 2003
Number of ways to write n as (x + 2^y), x >= 0. Number of ways to write n + 1 as 2^x + 3^y (cf. A004050). - Benoit Cloitre, Mar 29 2003
The minimum number of cuts for dividing an object into n (possibly unequal) pieces. - Karl Ove Hufthammer (karl(AT)huftis.org), Mar 29 2010
Partial sums of A209229; number of powers of 2 not greater than n. - Reinhard Zumkeller, Mar 07 2012

Examples

			a(1) = 0, since log_2(1) = 0.
a(2) = 1, since log_2(2) = 1.
a(3) = 2, since log_2(3) = 1.58...
a(n) = 7 for n = 65, 66, ..., 127, 128.
G.f. = x^2 + 2*x^3 + 2*x^4 + 3*x^5 + 3*x^6 + 3*x^7 + 3*x^8 + 4*x^9 + ... - _Michael Somos_, Jun 02 2019
		

References

  • R. L. Graham, D. E. Knuth and O. Patashnik, Concrete Mathematics, Addison-Wesley, 1989, p. 70.
  • G. J. E. Rawlins, Compared to What? An Introduction to the Analysis of Algorithms, W. H. Freeman, 1992; see pp. 108, 118.

Crossrefs

Partial sums of A036987.
Used for several definitions: A029827, A036378-A036390. Partial sums: A001855.

Programs

  • Haskell
    a029837 n = a029837_list !! (n-1)
    a029837_list = scanl1 (+) a209229_list
    -- Reinhard Zumkeller, Mar 07 2012
    (Common Lisp) (defun A029837 (n) (integer-length (1- n))) ; James Spahlinger, Oct 15 2012
    
  • Magma
    [Ceiling(Log(2, n)): n in [1..100]]; // Vincenzo Librandi, Jun 14 2019
    
  • Maple
    a:= n-> (p-> p+`if`(2^pAlois P. Heinz, Mar 18 2013
  • Mathematica
    a[n_] := Ceiling[Log[2, n]]; Array[a, 105] (* Robert G. Wilson v, Dec 09 2005 *)
    Table[IntegerLength[n - 1, 2], {n, 1, 105}] (* Peter Luschny, Dec 02 2017 *)
    a[n_] := If[n < 1, 0, BitLength[n - 1]]; (* Michael Somos, Jul 10 2018 *)
    Join[{0}, IntegerLength[Range[130], 2]] (* Vincenzo Librandi, Jun 14 2019 *)
  • PARI
    {a(n) = if( n<1, 0, ceil(log(n) / log(2)))};
    
  • PARI
    /* Set p = 1, then: */
    xpcount(n,p) = for(x=1, n, p1 = x; ct=0; while(p1>1, if(p1%2==0,p1/=2; ct++,p1 = p1*p+1)); print1(ct, ", "))
    
  • PARI
    {a(n) = if( n<2, 0, exponent(n-1)+1)}; /* Michael Somos, Jul 10 2018 */
    
  • Python
    def A029837(n):
        s = bin(n)[2:]
        return len(s) - (1 if s.count('1') == 1 else 0) # Chai Wah Wu, Jul 09 2020
    
  • Python
    def A029837(n): return (n-1).bit_length() # Chai Wah Wu, Jun 30 2022
  • Scala
    (1 to 80).map(n => Math.ceil(Math.log(n)/Math.log(2)).toInt) // Alonso del Arte, Feb 19 2020
    

Formula

a(n) = ceiling(log_2(n)).
a(1) = 0; for n > 1, a(2n) = a(n) + 1, a(2n + 1) = a(n) + 1. Alternatively, a(1) = 0; for n > 1, a(n) = a(ceiling(n/2)) + 1. [corrected by Ilya Gutkovskiy, Mar 21 2020]
a(n) = k such that n^(1/k - 1) > 2 > n^(1/k), or the least value of k for which floor n^(1/k) = 1. a(n) = k for all n such that 2^(k - 1) < n < 2^k. - Amarnath Murthy, May 06 2001
G.f.: x/(1 - x) * Sum_{k >= 0} x^2^k. - Ralf Stephan, Apr 13 2002
A062383(n-1) = 2^a(n). - Johannes W. Meijer, Jul 06 2009
a(n+1) = -Sum_{k = 1..n} mu(2*k)*floor(n/k). - Benoit Cloitre, Oct 21 2009
a(n+1) = A113473(n). - Michael Somos, Jun 02 2019

Extensions

Additional comments from Daniele Parisse
More terms from Michael Somos, Aug 02 2002

A000193 Nearest integer to log n.

Original entry on oeis.org

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

Views

Author

Keywords

Crossrefs

Programs

  • Haskell
    a000193 = round . log . fromIntegral  -- Reinhard Zumkeller, Mar 17 2015
  • Maple
    Digits := 100; f := n->round(evalf(log(n))); [ seq(f(n), n=1..100) ];
  • Mathematica
    Round[Log[Range[100]]] (* Paolo Xausa, Jun 28 2024 *)
  • PARI
    a(n)=round(log(n))
    

A004233 a(n) = ceiling(log(n)).

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Does not satisfy Benford's law [Whyman et al., 2016]. - N. J. A. Sloane, Feb 12 2017

Crossrefs

Programs

A016040 Integer part of Chebyshev's theta function: floor( log(Product_{k=1..n} prime(k)) ).

Original entry on oeis.org

0, 1, 3, 5, 7, 10, 13, 16, 19, 22, 26, 29, 33, 37, 40, 44, 49, 53, 57, 61, 65, 70, 74, 79, 83, 88, 92, 97, 102, 107, 111, 116, 121, 126, 131, 136, 141, 146, 151, 157, 162, 167, 172, 177, 183, 188, 193, 199, 204, 210, 215, 221, 226, 232, 237, 243, 248
Offset: 1

Views

Author

Keywords

Crossrefs

Cf. A035158.

Programs

  • Mathematica
    Table[Floor[N[Sum[Log[Prime[x]], {x, 1, n}]]], {n, 1, 1000}] (* Artur Jasinski, Jan 23 2007 *)

Formula

a(n) = A000195(A002110(n)).
a(n) ~ n log n by the prime number theorem. - Charles R Greathouse IV, Dec 11 2008

Extensions

New name from Charles R Greathouse IV, Dec 11 2008

A114650 a(1)=1. For n>1, a(n) is smallest positive integer not among the earlier terms of the sequence such that floor(log(a(n))) does not equal floor(log(a(n-1))).

Original entry on oeis.org

1, 3, 2, 4, 8, 5, 9, 6, 10, 7, 11, 21, 12, 22, 13, 23, 14, 24, 15, 25, 16, 26, 17, 27, 18, 28, 19, 29, 20, 30, 55, 31, 56, 32, 57, 33, 58, 34, 59, 35, 60, 36, 61, 37, 62, 38, 63, 39, 64, 40, 65, 41, 66, 42, 67, 43, 68, 44, 69, 45, 70, 46, 71, 47, 72, 48, 73, 49, 74, 50, 75, 51
Offset: 1

Views

Author

Leroy Quet, Dec 21 2005

Keywords

Comments

Sequence is a permutation of the positive integers. (Sequence A114651 is the inverse permutation.)
Apparently this permutation is completely decomposable into (disjoint) cycles of finite length. The number of fixed points (cf. A114726) seems to be infinite, but for each k>1 there are presumably only finitely many cycles of length k (cf. A114727 and A114728). - Klaus Brockhaus, Dec 29 2005

Examples

			Since all positive integers m where floor(log(m)) equals 0 or 1 occur among the first 11 terms of the sequence and since floor(log(a(11))) = 2, then a(12) must be 21 (which is the smallest positive integer m such that floor(log(m)) = 3).
		

Crossrefs

Extensions

More terms from Klaus Brockhaus, Dec 25 2005
Showing 1-10 of 23 results. Next