A191682 Twice A113473.
2, 4, 4, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
Offset: 1
Crossrefs
Cf. A113473.
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.
8 = 1000 in binary has length 4.
a070939 n = if n < 2 then 1 else a070939 (n `div` 2) + 1 a070939_list = 1 : 1 : l [1] where l bs = bs' ++ l bs' where bs' = map (+ 1) (bs ++ bs) -- Reinhard Zumkeller, Jul 19 2012, Jun 07 2011
A070939:=func< n | n eq 0 select 1 else #Intseq(n, 2) >; [ A070939(n): n in [0..104] ]; // Klaus Brockhaus, Jan 13 2011
A070939 := n -> `if`(n=0, 1, ilog2(2*n)): seq(A070939(n), n=0..104); # revised by Peter Luschny, Aug 10 2017
Table[Length[IntegerDigits[n, 2]], {n, 0, 50}] (* Stefan Steinerberger, Apr 01 2006 *) Join[{1},IntegerLength[Range[110],2]] (* Harvey P. Dale, Aug 18 2013 *) a[ n_] := If[ n < 1, Boole[n == 0], BitLength[n]]; (* Michael Somos, Jul 10 2018 *)
{a(n) = if( n<1, n==0, #binary(n))} /* Michael Somos, Aug 31 2012 */
apply( {A070939(n)=exponent(n+!n)+1}, [0..99]) \\ works for negative n and is much faster than the above. - M. F. Hasler, Jan 04 2014, updated Feb 29 2020
def a(n): return len(bin(n)[2:]) print([a(n) for n in range(105)]) # Michael S. Branicky, Jan 01 2021
def A070939(n): return 1 if n == 0 else n.bit_length() # Chai Wah Wu, May 12 2022
def A070939(n) : return (2*n).exact_log(2) if n != 0 else 1 [A070939(n) for n in range(100)] # Peter Luschny, Aug 08 2012
a(5)=2 because the binary expansion of 5 (=101) has three bits.
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
[Ilog2(n) : n in [1..130] ];
A000523 := proc(n) ilog2(n) ; end proc: # R. J. Mathar, Nov 28 2016 seq(A000523(n), n=1..90);
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 *)
{a(n) = floor(log(n) / log(2))} \\ Likely to yield incorrect results for many if not almost all n. Better use most recent code.
{a(n) = if( n<1, 0, #binary(n) - 1)}; /* Michael Somos, May 28 2014 */
a(n)=logint(n,2) \\ Charles R Greathouse IV, Sep 01 2015
a(n)=exponent(n) \\ Charles R Greathouse IV, Nov 09 2017
def A000523(n): return len(bin(n))-3 # Chai Wah Wu, Jul 09 2020
def a(n): return n.bit_length() - 1 print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Apr 18 2023
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
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
[Ceiling(Log(2, n)): n in [1..100]]; // Vincenzo Librandi, Jun 14 2019
a:= n-> (p-> p+`if`(2^pAlois P. Heinz, Mar 18 2013
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 *)
{a(n) = if( n<1, 0, ceil(log(n) / log(2)))};
/* 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, ", "))
{a(n) = if( n<2, 0, exponent(n-1)+1)}; /* Michael Somos, Jul 10 2018 */
def A029837(n): s = bin(n)[2:] return len(s) - (1 if s.count('1') == 1 else 0) # Chai Wah Wu, Jul 09 2020
def A029837(n): return (n-1).bit_length() # Chai Wah Wu, Jun 30 2022
(1 to 80).map(n => Math.ceil(Math.log(n)/Math.log(2)).toInt) // Alonso del Arte, Feb 19 2020
Row n is given by the exponents in the binary expansion of 2*n. For example, row 5 = [3, 1] because 2*5 = 2^3 + 2^1. Row 0: [] Row 1: [1] Row 2: [2] Row 3: [2, 1] Row 4: [3] Row 5: [3, 1] Row 6: [3, 2] Row 7: [3, 2, 1]
T:= proc(n) local i, l, m; l:= NULL; m:= n; if n=0 then return [][] fi; for i while m>0 do if irem(m, 2, 'm')=1 then l:=i, l fi od; l end: seq(T(n), n=0..35); # Alois P. Heinz, Nov 27 2024
Table[Reverse[Join@@Position[Reverse[IntegerDigits[n,2]],1]],{n,0,100}] (* Gus Wiseman, Jan 17 2023 *)
T(6,2) = 3: 3, 5, 6, or in binary: 11_2, 101_2, 110_2. T(15,3) = 4: 7, 11, 13, 14, or in binary: 111_2, 1011_2, 1101_2, 1110_2. Triangle T(n,k) begins: 1; 1, 1; 1, 2; 1, 2, 1; 1, 3, 1; 1, 3, 2; 1, 3, 3; 1, 3, 3, 1; 1, 4, 3, 1; 1, 4, 4, 1; 1, 4, 5, 1; 1, 4, 5, 2; 1, 4, 6, 2; 1, 4, 6, 3; 1, 4, 6, 4; 1, 4, 6, 4, 1; ...
b:= proc(n) option remember; `if`(n<0, 0, b(n-1)+x^add(i, i=Bits[Split](n))) end: T:= n-> (p-> seq(coeff(p, x, i), i=0..degree(p)))(b(n)): seq(T(n), n=0..23);
T(n,k) = my(v1); v1 = Vecrev(binary(n+1)); v1 = Vecrev(select(x->(x>0),v1,1)); sum(j=0, min(k,#v1-1), binomial(v1[j+1]-1,k-j)) \\ Mikhail Kurkov, Nov 27 2024
Array begins: n\k| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ---+----------------------------------------------------------------------------- 1 | 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 2 | 4, 4, 8, 5, 6, 6, 8, 6, 7, 6, 12, 7, 8, 7, 3 | 12, 12, 20, 10, 13, 11, 20, 11, 16, 13, 28, 11, 14, 12, 4 | 28, 28, 44, 19, 26, 24, 44, 19, 36, 26, 60, 24, 29, 23, 5 | 60, 60, 92, 40, 51, 52, 92, 40, 76, 51, 124, 52, 58, 44, 6 | 124, 124, 188, 84, 104, 108, 188, 84, 156, 104, 252, 108, 115, 84, 7 | 252, 252, 380, 172, 212, 220, 380, 172, 316, 212, 508, 220, 232, 165, 8 | 508, 508, 764, 348, 428, 444, 764, 348, 636, 428, 1020, 444, 468, 326, 9 | 1020, 1020, 1532, 700, 860, 892, 1532, 700, 1276, 860, 2044, 892, 940, 650,
up_to = 78; A000523(n) = logint(n,2); A371094(n) = { my(m=1+3*n, e=valuation(m,2)); ((m*(2^e)) + (((4^e)-1)/3)); }; A372282sq(n,k) = if(1==n,2*k-1,A371094(A372282sq(n-1,k))); A372354sq(n,k) = A000523(A372282sq(n,k)); A372354list(up_to) = { my(v = vector(up_to), i=0); for(a=1,oo, for(col=1,a, i++; if(i > up_to, return(v)); v[i] = A372354sq((a-(col-1)),col))); (v); }; v372354 = A372354list(up_to); A372354(n) = v372354[n];
The circulant matrix for n = 23 = 10111_2 is [1 0 1 1 1] [1 1 0 1 1] [1 1 1 0 1] [1 1 1 1 0] [0 1 1 1 1] and has permanent 44, thus a(23) = 44. a(10) = 4 != a(12) = 2 although 10 = 1010_2 and 12 = 1100_2 have the same number of 0's and 1's.
a:= n-> (l-> LinearAlgebra[Permanent](Matrix(nops(l), shape=Circulant[l])))(convert(n, base, 2)): seq(a(n), n=0..100);
Triangle begins: 1; 1,1; 2; 2,1; 2,1,1; 2,2; 3; 3,1; 3,1,1; 3,2; 3,2,1; 3,3; 4; 4,1; 4,1,1; 4,2; 4,2,1; 4,2,1,1; 4,2,2; 4,3; 4,3,1; 4,4; ... Row n = 5 starts with S_1 = 5. We append 1 to get {5,1}. 1 does not exceed 5, thus S_2 = {5,1}. We append 1 to get {5,1,1}. A = {1,2}; {5,1}-{2,1} = {3,0}, thus S_3 = {5,1,1} and we drop the last term and increment the new last term to get {5,2}. S_4 = {5,2}, and the ensuing terms {5,2,1}, {5,2,1,1}, {5,2,2} enter into the row. Since there are repeated terms at the last sequence, we drop the last term and increment the new last to get {5,3}. The terms {5,3,1}, {5,3,1,1}, {5,3,2}, {5,3,2,1}, are admitted. {5,3,2,1,1} has A = {1,2,4,6}. {5,3,2,1}-{6,4,2,1} = {-1,1,0,0}: {5,3,2,1,1} cannot be admitted, so we drop the last term and increment to {5,3,2,2} but the sum of the last two terms exceeds the second and we drop the last term and increment to {5,3,3}. For similar reasons, this cannot be admitted, so we drop the last term and increment to {5,4}. This enters as well as {5,4,1}. Since any appendage or increment proves invalid, we end up incrementing to {5,5}. The two terms are the same, therefore we end the row n = 5.
(* Generate sequence: *) f[n_] := Block[{w = {n}, c}, c[x_] := Apply[Times, Most@ x - Reverse@ Accumulate@ Reverse@ Rest@ x]; Reap[Do[Which[And[Length@ w == 2, SameQ @@ w], Sow[w]; Break[], Length@ w == 1, Sow[w]; AppendTo[w, 1], c[w] > 0, Sow[w]; AppendTo[w, 1], True, Sow[w]; w = MapAt[1 + # &, Drop[w, -1], -1]], {i, Infinity}] ][[-1, 1]] ]; Array[f, 6] // Flatten (* Convert S = row n to standard partition: *) g[w_] := Block[{k}, k = Total@ w; Total@ Map[Apply[Function[{s, t}, s Array[Boole[t <= # <= s + t - 1] &, k] ], #] &, Apply[Join, Prepend[Table[Function[{v, c}, Map[{w[[k]], # + 1} &, Map[Total[v #] &, Tuples[{0, 1}, {Length@ v}]]]] @@ {Most@ #, ConstantArray[1, Length@ # - 1]} &@ Take[w, k], {k, 2, Length@ w}], {{w[[1]], 1}}]]] ]
a(6) = 20: {}, {1,3}, {1,5}, {1,6}, {2,3}, {2,5}, {2,6}, {3,4}, {4,5}, {4,6}, {1,2,3,5}, {1,2,3,6}, {1,2,5,6}, {1,3,4,5}, {1,3,4,6}, {1,4,5,6}, {2,3,4,5}, {2,3,4,6}, {2,4,5,6}, {1,2,3,4,5,6}.
a:= n-> binomial(n, max(0, 1+ilog[2](n))): seq(a(n), n=0..40);
from math import comb def A357812(n): return comb(n,n.bit_length()) # Chai Wah Wu, Oct 14 2022
Comments