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

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

A036386 Number of prime powers (p^2, p^3, ...) <= 2^n.

Original entry on oeis.org

0, 1, 2, 4, 7, 9, 13, 16, 20, 26, 31, 40, 50, 61, 78, 93, 119, 150, 189, 242, 310, 400, 525, 684, 900, 1190, 1581, 2117, 2836, 3807, 5136, 6948, 9425, 12811, 17437, 23788, 32517, 44512, 60971, 83640, 114899, 157948, 217336, 299360, 412635, 569193, 785753, 1085319, 1500140, 2074794, 2870849, 3974425, 5504966
Offset: 1

Views

Author

Keywords

Examples

			For n = 6, there are 9 prime powers not exceeding 2^6 = 64: 4, 8, 9, 16, 25, 27, 32, 49, 64, so a(6) = 9.
For n = 25, a(25) = 900, pi(5792) + pi(322) + pi(76) + pi(32) + pi(17) + pi(11) + pi(8) + pi(6) + pi(5) + pi(4) + pi(4) + pi(3) + pi(3) + pi(3) + pi(2) + pi(2) + pi(2) + pi(2) + pi(2) + pi(2) + pi(2) + pi(2) + pi(2) + pi(2) + pi(1) = 760 + 66 + 21 + 11 + 7 + 5 + 4 + 3 + 3 + 2 + 2 + 2 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 = 900.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := Length@ Union@ Flatten@ Table[ Prime[j]^k, {k, 2, n + 1}, {j, PrimePi[2^(n/k)]}]; Array[f, 46] (* Robert G. Wilson v, Jul 08 2011 *)
  • Python
    from sympy import primepi, integer_nthroot
    def A036386(n):
        m = 1<Chai Wah Wu, Jan 23 2025

Formula

a(n) = Sum_{j=2..n+1} pi(floor(2^(n/j))). The summation starts with squares (j=2); for arbitrary range (=y), the y^(1/j) argument has to be used.

Extensions

More terms from Labos Elemer, May 07 2001
Terms a(47) and beyond from Hiroaki Yamanouchi, Nov 15 2016

A029827 Composite connected numbers: composite numbers k such that g(k) < g(u) + g(v) holds for all relatively prime factorizations k=u*v, where g(x) = ceiling(log_2 x).

Original entry on oeis.org

15, 45, 51, 55, 57, 63, 85, 95, 99, 111, 115, 117, 119, 123, 153, 171, 185, 187, 201, 205, 207, 209, 213, 215, 219, 221, 225, 231, 235, 237, 245, 247, 249, 253, 255, 323, 333, 335, 355, 365, 369, 387, 391, 393, 395, 405, 407, 411, 415, 417, 423, 425, 429
Offset: 1

Views

Author

Keywords

Comments

Prime powers are not connected since they have no relatively prime factorizations. - Michel Marcus, Feb 25 2014

Examples

			k = 46665 = 5*9*17*61 is not a connected number because k = 61*765, but 16 >= 6 + 10.
		

References

  • E. Labos, Spike Generating Dynamical Systems and Networks, In Lect. Notes in Economics and Mathematical Systems, pp. 189-206. Springer Verlag 1985.

Crossrefs

Programs

  • PARI
    g(n) = ceil(log(n)/log(2));
    isok(n) = {if (isprime(n), return (0)); d = divisors(n); gn = g(n); bpf = 0; for (i=2, #d-1, di = d[i]; if (gcd(di, n/di)==1, bpf = 1; if (gn >= g(di)+g(n/di), return (0)););); return (bpf);} \\ Michel Marcus, Feb 25 2014

Extensions

a(40) corrected by Sean A. Irvine, Mar 05 2020

A036382 Odd split numbers: have a nontrivial factorization n=ab with a and b coprime, so that L(a) + L(b) <= L(n), where L(x) = A029837(x) = ceiling(log_2(x)).

Original entry on oeis.org

21, 33, 35, 39, 65, 69, 75, 77, 87, 91, 93, 105, 129, 133, 135, 141, 143, 145, 147, 155, 159, 161, 165, 175, 177, 183, 189, 195, 203, 217, 259, 261, 265, 267, 273, 275, 279, 285, 287, 291, 295, 297, 299, 301, 303, 305, 309, 315, 319, 321, 325, 327, 329, 339
Offset: 1

Views

Author

Keywords

Comments

All even numbers are split numbers, except that prime powers -- here powers of 2 -- are by definition excluded.
The gaps g(n) = a(n+1) - a(n) are growing up to some local maximum before suddenly dropping down to a very small value and starting a new cycle of growth. The local maxima, distinctly seen as kinks in the graph, are g(1) = 12, g(4) = 26, g(12) = 24, g(30) = 42, g(70) = 48, g(157) = 110, g(348) = 96, g(748) = 160, g(1603) = 192, g(3379) = 446, g(7076) = 384, ... They occur at indices slightly larger than twice the preceding one; every other is of size 6*2^k, k = 1,2,3,... while those in between don't seem to follow a simple pattern and are sometimes larger than the subsequent gap of size 6*2^k. - M. F. Hasler, Apr 15 2017

Examples

			s = 39 is a split number since s = 39 = 3*13, gcd(3,13)=1 and L(3) + L(13) = 2 + 4 = L(39).
		

Crossrefs

Programs

  • Mathematica
    Select[Range[1, 340, 2], Function[n, Total@ Boole@ Map[And[Total@ Ceiling@ Log2@ # <= Ceiling@ Log2@ n, CoprimeQ @@ #] &, Map[{#, n/#} &, Rest@ Take[#, Ceiling[Length[#]/2]]]] > 0 &@ Divisors@ n]] (* Michael De Vlieger, Mar 03 2017 *)

Extensions

Name corrected by Michael De Vlieger, Mar 03 2017

A036380 Number of true prime powers whose binary order, ceiling(log_2(p^x)), is n.

Original entry on oeis.org

0, 1, 1, 2, 3, 2, 4, 3, 4, 6, 5, 9, 10, 11, 17, 15, 26, 31, 39, 53, 68, 90, 125, 159, 216, 290, 391, 536, 719, 971, 1329, 1812, 2477, 3386, 4626, 6351, 8729, 11995, 16459, 22669, 31259, 43049, 59388, 82024, 113275, 156558, 216560, 299566, 414821, 574654
Offset: 1

Views

Author

Keywords

Examples

			There are 5 prime powers between 2^10 + 1 = 1025 and 2^11 = 2048 (inclusive): 1331 = 11^3, 1369 = 37^2, 1681 = 41^2, 1849 = 43^2, and 2048 = 2^11, so a(11) = 5.
		

Crossrefs

Programs

  • Mathematica
    t=Table[Length[Union[Flatten[Table[Table[Prime[w]^s, {w, 1, PrimePi[2^(n/s)]}], {s, 2, g+1}]]] ], {n, 1, 42}]; Delete[t-RotateRight[t], 1]

Formula

a(n) = A036386(n) - A036386(n-1) for n >= 2. - Amiram Eldar, Mar 22 2025

Extensions

More terms from Sean A. Irvine, Oct 29 2020

A036381 Number of connected numbers (A029827) in the interval [2^(n-1)+1, 2^n].

Original entry on oeis.org

0, 0, 0, 1, 0, 5, 8, 21, 42, 89, 180, 361, 720, 1438, 2867, 5696, 11282, 22392, 44340, 87887, 174045, 344719, 682767, 1352375, 2678305, 5305631, 10510870, 20824910, 41264654, 81776998, 162083352, 321295873
Offset: 1

Views

Author

Keywords

Examples

			From the 64 numbers with ceiling(log_2(x)) = 7, the following 8 are composite connected numbers: 85, 95, 99, 111, 115, 117, 119, 123. Among the others 13 primes, 4 true prime powers and 39 split numbers can be found.
		

Crossrefs

Extensions

a(21)-a(32) from Sean A. Irvine, Oct 29 2020

A036384 Number of odd split numbers (A036382) in the interval [2^(n-1), 2^n].

Original entry on oeis.org

0, 0, 0, 0, 1, 3, 8, 18, 40, 87, 191, 400, 855, 1776, 3697, 7644, 15752, 32365, 66304, 135570, 276590, 563432, 1146045, 2328063, 4724270, 9577176, 19397428, 39256129, 79390449, 160450210, 324088695, 654261484
Offset: 1

Views

Author

Keywords

Examples

			Out of the 512 numbers with "binary order" ceiling(log_2(x)) = 10, there are 87 odd split numbers.
		

Crossrefs

Extensions

Name simplified by M. F. Hasler, Apr 19 2017
a(21)-a(32) from Giovanni Resta, Apr 21 2017

A036385 Number of split numbers (A036382) with binary order (A029837) n, i.e., those in interval [ 2^(n-1), 2^n ].

Original entry on oeis.org

0, 0, 1, 3, 8, 18, 39, 81, 167, 342, 702, 1423, 2902, 5871, 11888, 24027, 48519, 97900, 197375, 397713, 800877, 1612007, 3243196, 6522366, 13112877, 26354391, 52951859, 106364992, 213608176, 428885665, 860959606
Offset: 1

Views

Author

Keywords

Examples

			Out of the 128 numbers with the binary order 8, there are 81 split numbers (odd + even); so a(7)=81.
		

Crossrefs

Extensions

a(20)-a(31) from Sean A. Irvine, Oct 29 2020

A036383 First differences of odd split numbers (A036382).

Original entry on oeis.org

12, 2, 4, 26, 4, 6, 2, 10, 4, 2, 12, 24, 4, 2, 6, 2, 2, 2, 8, 4, 2, 4, 10, 2, 6, 6, 6, 8, 14, 42, 2, 4, 2, 6, 2, 4, 6, 2, 4, 4, 2, 2, 2, 2, 2, 4, 6, 4, 2, 4, 2, 2, 10, 2, 4, 6, 6, 6, 8, 4, 2, 4, 4, 14, 4, 10, 14, 8, 30, 48, 2, 2, 2, 6, 2, 4, 2, 2, 2, 2, 4, 2, 4, 2, 2, 2, 4, 2, 4, 2, 6, 2, 4, 2, 2, 2, 4, 2
Offset: 1

Views

Author

Keywords

Comments

The large local maxima are near powers of 2. Compare the differences of connected numbers (A036379).
Densities of connected (A029827) and split (A036382) numbers seem to behave in opposite way: where connected are dense, split ones are rare and vice versa.

Examples

			177, 183, 189, 195, 203, 217, 259, 261 are successive odd split numbers, so their sequence of first differences is 6, 6, 6, 8, 14, 42, 2.
		

Crossrefs

A036387 Number of connected numbers (A029827) with binary order (A029837) <= n.

Original entry on oeis.org

0, 0, 0, 1, 1, 6, 14, 35, 77, 166, 346, 707, 1427, 2865, 5732, 11428, 22710, 45102, 89442, 177329, 351374, 696093, 1378860, 2731235, 5409540, 10715171, 21226041, 42050951, 83315605, 165092603, 327175955
Offset: 1

Views

Author

Keywords

Examples

			Below 64 the following six composite connected numbers occur: 15,45,51,55,57,63, so a(6)=6.
		

Crossrefs

Extensions

a(21)-a(31) from Sean A. Irvine, Oct 29 2020
Showing 1-10 of 11 results. Next