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.

Previous Showing 31-40 of 2056 results. Next

A088705 First differences of A000120. One minus exponent of 2 in n.

Original entry on oeis.org

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

Views

Author

Ralf Stephan, Oct 10 2003

Keywords

Comments

The number of 1's in the binary expansion of n+1 minus the number of 1's in the binary expansion of n.

Crossrefs

Programs

  • Haskell
    a088705 n = a088705_list !! n
    a088705_list = 0 : zipWith (-) (tail a000120_list) a000120_list
    -- Reinhard Zumkeller, Dec 11 2011
    
  • Maple
    add(x^(2^k)/(1+x^(2^k)),k=0..20); series(%,x,1001); seriestolist(%); # To get up to a million terms, from N. J. A. Sloane, Aug 31 2014
  • Mathematica
    a[n_] := If[n<1, 0, If[Mod[n, 2] == 0, a[n/2] - 1, 1]]; Array[a, 60, 0] (* Amiram Eldar, Nov 26 2018 *)
  • PARI
    a(n)=if(n<1,0,if(n%2==0,a(n/2)-1,1))
    
  • PARI
    a(n)=if(n<1,0,1-valuation(n,2))
    
  • Python
    def A088705(n): return 1-(~n & n-1).bit_length() # Chai Wah Wu, Sep 18 2024

Formula

For n > 0: a(n) = A000120(n) - A000120(n-1) = 1 - A007814(n).
Multiplicative with a(2^e) = 1-e, a(p^e) = 1 otherwise. - David W. Wilson, Jun 12 2005
G.f.: Sum{k>=0} t/(1+t), t=x^2^k.
a(0) = 0, a(2*n) = a(n) - 1, a(2*n+1) = 1.
Let T(x) be the g.f., then T(x)-T(x^2)=x/(1+x). - Joerg Arndt, May 11 2010
Dirichlet g.f.: zeta(s) * (2-2^s)/(1-2^s). - Amiram Eldar, Sep 18 2023

A218254 Irregular table, where row n (n >= 0) starts with n, the next term is n-A000120(n), and the successive terms are obtained by repeatedly subtracting the number of 1's in the previous term's binary expansion, until zero is reached, after which the next row starts with one larger n.

Original entry on oeis.org

0, 1, 0, 2, 1, 0, 3, 1, 0, 4, 3, 1, 0, 5, 3, 1, 0, 6, 4, 3, 1, 0, 7, 4, 3, 1, 0, 8, 7, 4, 3, 1, 0, 9, 7, 4, 3, 1, 0, 10, 8, 7, 4, 3, 1, 0, 11, 8, 7, 4, 3, 1, 0, 12, 10, 8, 7, 4, 3, 1, 0, 13, 10, 8, 7, 4, 3, 1, 0, 14, 11, 8, 7, 4, 3, 1, 0, 15, 11, 8, 7, 4, 3, 1, 0
Offset: 0

Views

Author

Nico Brown, Oct 24 2012

Keywords

Examples

			The n-th row (starting indexing from zero) in this irregular table consists of block of length A071542(n)+1: 1,2,3,3,4,4,5,5,... which always ends with zero, as:
0
1,0
2,1,0
3,1,0
4,3,1,0
5,3,1,0
6,4,3,1,0
7,4,3,1,0
The 17th term is 6, which in binary is 110. The 18th term is then 6-2=4.
		

Crossrefs

Cf. A218252, A218253. A213707 gives the positions of zeros (i.e. the ending index of each row). A071542, A000120.
The reversed tails of the rows converge towards A179016.

Programs

  • PARI
    for(n=0,9,k=n;while(k, print1(k", "); k-=hammingweight(k)); print1("0, ")) \\ Charles R Greathouse IV, Oct 30 2012

A230092 Numbers of the form k + wt(k) for exactly three distinct k, where wt(k) = A000120(k) is the binary weight of k.

Original entry on oeis.org

129, 134, 386, 391, 515, 518, 642, 647, 899, 904, 1028, 1030, 1154, 1159, 1411, 1416, 1540, 1543, 1667, 1672, 1924, 1929, 2178, 2183, 2435, 2440, 2564, 2567, 2691, 2696, 2948, 2953, 3077, 3079, 3203, 3208, 3460, 3465, 3589, 3592, 3716, 3721, 3973, 3978, 4226
Offset: 1

Views

Author

N. J. A. Sloane, Oct 10 2013

Keywords

Comments

The positions of entries equal to 3 in A228085, or numbers that appear exactly thrice in A092391.
Numbers that can be expressed as the sum of distinct terms of the form 2^n+1, n=0,1,... in exactly three ways.

Crossrefs

Programs

  • Haskell
    a230092 n = a230092_list !! (n-1)
    a230092_list = filter ((== 3) . a228085) [1..]
    -- Reinhard Zumkeller, Oct 13 2013
  • Maple
    For Maple code see A230091.
  • Mathematica
    nt = 1000; (* number of terms to produce *)
    S[kmax_] := S[kmax] = Table[k + Total[IntegerDigits[k, 2]], {k, 0, kmax}] // Tally // Select[#, #[[2]] == 3&][[All, 1]]& // PadRight[#, nt]&;
    S[nt];
    S[kmax = 2 nt];
    While[S[kmax] =!= S[kmax/2], kmax *= 2];
    S[kmax] (* Jean-François Alcover, Mar 04 2023 *)

A151685 a(n) = Sum_{k >= 0} bin2(wt(n+k),k+1), where bin2(i,j) = A013609(i,j), wt(i) = A000120(i).

Original entry on oeis.org

3, 7, 5, 7, 17, 17, 7, 7, 17, 17, 19, 41, 51, 31, 9, 7, 17, 17, 19, 41, 51, 31, 21, 41, 51, 55, 101, 143, 113, 49, 11, 7, 17, 17, 19, 41, 51, 31, 21, 41, 51, 55, 101, 143, 113, 49, 23, 41, 51, 55, 101, 143, 113, 73, 103, 143, 161, 257, 387, 369, 211, 71, 13, 7, 17, 17, 19, 41, 51
Offset: 0

Views

Author

N. J. A. Sloane, Jun 01 2009

Keywords

Comments

Or, a(n) = Sum_{k >= 0} 2^wt(k) * binomial(wt(n+k),k).

Examples

			Contribution from _Omar E. Pol_, Jun 09 2009: (Start)
Triangle begins:
.3;
.7,5;
.7,17,17,7;
.7,17,17,19,41,51,31,9;
.7,17,17,19,41,51,31,21,41,51,55,101,143,113,49,11;
.7,17,17,19,41,51,31,21,41,51,55,101,143,113,49,23,41,51,55,101,143,113,...
(End)
		

Crossrefs

For generating functions of the form Product_{k>=c} (1+a*x^(2^k-1)+b*x^2^k) for the following values of (a,b,c) see: (1,1,0) A160573, (1,1,1) A151552, (1,1,2) A151692, (2,1,0) A151685, (2,1,1) A151691, (1,2,0) A151688 and A152980, (1,2,1) A151550, (2,2,0) A151693, (2,2,1) A151694.
Cf. A000079. - Omar E. Pol, Jun 09 2009

Programs

  • Maple
    bin2:=proc(n,k) option remember; if k<0 or k>n then 0
    elif k=0 then 1 else 2*bin2(n-1,k-1)+bin2(n-1,k); fi; end;
    wt := proc(n) local w,m,i;
    w := 0; m := n; while m > 0 do i := m mod 2; w := w+i; m := (m-i)/2; od; w; end:
    f:=n->add( bin2(wt(n+k),k),k=0..120 );
    # or:
    f := n->add( 2^k*binomial(wt(n+k),k),k=0..20 );
  • Mathematica
    max = 70; (* number of terms *)
    CoefficientList[Product[1 + 2*x^(2^k-1) + x^(2^k), {k, 0, Log2[max+1] // Ceiling}] + O[x]^max, x] (* Jean-François Alcover, Aug 03 2022 *)

Formula

G.f.: Product_{ k >= 0 } (1 + 2*x^(2^k-1) + x^(2^k)).

A227915 Numbers of the form k + wt(k) for exactly four distinct k, where wt(k) = A000120(k) is the binary weight of k.

Original entry on oeis.org

4102, 12295, 20487, 28680, 36871, 45064, 53256, 61449, 69639, 77832, 86024, 94217, 102408, 110601, 118793, 126986, 135175, 143368, 151560, 159753, 167944, 176137, 184329, 192522, 200712, 208905, 217097, 225290, 233481, 241674, 249866, 258059, 266247, 274440, 282632, 290825, 299016, 307209, 315401, 323594, 331784, 339977
Offset: 1

Views

Author

Reinhard Zumkeller, Oct 13 2013

Keywords

Comments

Numbers occurring exactly four times in A092391: A228085(a(n)) = 4. For the first number that appears k times, see A230303.

Examples

			a(1) = 4102, the four k with A092391(k) = 4102 being:
4091 = '111111111011', A000120(4091) = 11, 4091 + 11 = 4102;
4092 = '111111111100', A000120(4092) = 12, 4092 + 10 = 4102;
4099 = '1000000000011', A000120(4099) = 3, 4099 + 3 = 4102;
4100 = '1000000000100', A000120(4100) = 2, 4100 + 2 = 4102.
		

Crossrefs

Programs

  • Haskell
    a227915 n = a227915_list !! (n-1)
    a227915_list = filter ((== 4) . a228085) [1..]

A246588 Run Length Transform of S(n) = wt(n) = 0,1,1,2,1,2,2,3,1,... (cf. A000120).

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Sep 05 2014

Keywords

Comments

The Run Length Transform of a sequence {S(n), n>=0} is defined to be the sequence {T(n), n>=0} given by T(n) = Product_i S(i), where i runs through the lengths of runs of 1's in the binary expansion of n. E.g. 19 is 10011 in binary, which has two runs of 1's, of lengths 1 and 2. So T(19) = S(1)*S(2). T(0)=1 (the empty product).

Crossrefs

Cf. A000120.
Run Length Transforms of other sequences: A071053, A227349, A246595, A246596, A246660, A246661, A246674.

Programs

  • Haskell
    import Data.List (group)
    a246588 = product . map (a000120 . length) .
              filter ((== 1) . head) . group . a030308_row
    -- Reinhard Zumkeller, Feb 13 2015, Sep 05 2014
    
  • Maple
    A000120 := proc(n) local w, m, i; w := 0; m :=n; while m > 0 do i := m mod 2; w := w+i; m := (m-i)/2; od; w; end: wt := A000120;
    ans:=[];
    for n from 0 to 100 do lis:=[]; t1:=convert(n, base, 2); L1:=nops(t1); out1:=1; c:=0;
    for i from 1 to L1 do
       if out1 = 1 and t1[i] = 1 then out1:=0; c:=c+1;
       elif out1 = 0 and t1[i] = 1 then c:=c+1;
       elif out1 = 1 and t1[i] = 0 then c:=c;
       elif out1 = 0 and t1[i] = 0 then lis:=[c, op(lis)]; out1:=1; c:=0;
       fi;
       if i = L1 and c>0 then lis:=[c, op(lis)]; fi;
                       od:
    a:=mul(wt(i), i in lis);
    ans:=[op(ans), a];
    od:
    ans;
  • Mathematica
    f[n_] := DigitCount[n, 2, 1]; Table[Times @@ (f[Length[#]]&)  /@ Select[ Split[ IntegerDigits[n, 2]], #[[1]] == 1&], {n, 0, 100}] (* Jean-François Alcover, Jul 11 2017 *)
  • Python
    from operator import mul
    from functools import reduce
    from re import split
    def A246588(n):
        return reduce(mul,(bin(len(d)).count('1') for d in split('0+',bin(n)[2:]) if d)) if n > 0 else 1 # Chai Wah Wu, Sep 07 2014
    
  • Sage
    # uses[RLT from A246660]
    A246588_list = lambda len: RLT(lambda n: sum(Integer(n).digits(2)), len)
    A246588_list(88) # Peter Luschny, Sep 07 2014

A120738 a(n) = 4*n - A000120(n).

Original entry on oeis.org

0, 3, 7, 10, 15, 18, 22, 25, 31, 34, 38, 41, 46, 49, 53, 56, 63, 66, 70, 73, 78, 81, 85, 88, 94, 97, 101, 104, 109, 112, 116, 119, 127, 130, 134, 137, 142, 145, 149, 152, 158, 161, 165, 168, 173, 176, 180, 183, 190, 193, 197, 200, 205, 208, 212, 215, 221, 224, 228
Offset: 0

Views

Author

Paul Barry, Jun 29 2006

Keywords

Comments

Partial sums of A090739.
a(n) is also the increasing sequence of exponents of x in Product_{k > 1} (1 + x^(2^k - 1)). - Paul Pearson (ppearson(AT)rochester.edu), Aug 06 2008
Related to partial sums of the Ruler sequence A001511 by a(n) = A005187(2n), therefore {a(n)+1} are the indices of 1's in A252488. - M. F. Hasler, Jan 22 2015

Crossrefs

Programs

  • Magma
    A120738:= func< n | 4*n-(&+Intseq(n, 2)) >;
    [A120738(n): n in [0..100]]; // G. C. Greubel, Oct 20 2024
  • Maple
    a:=n->simplify(log[2](16^n/(add(modp(binomial(n,k),2),k=0..n))));
    a:=n->simplify(log[2](16^n/(2^(n-(padic[ordp](n!,2)))))); # Note: n-(padic[ordp](n!,2)) is the number of 1's in the binary expansion of n. - Paul Pearson (ppearson(AT)rochester.edu), Aug 06 2008
  • Mathematica
    Table[4 n - DigitCount[n, 2, 1], {n, 0, 58}] (* Michael De Vlieger, Nov 06 2016 *)
  • PARI
    {a(n) = if( n < 0, 0, 4*n - subst( Pol( binary( n ) ), x, 1) ) } /* Michael Somos, Aug 28 2007 */
    
  • PARI
    a(n) = 4*n - hammingweight(n); \\ Michel Marcus, Nov 06 2016
    
  • Python
    # Python 3.10
    def A120738(n): return (n<<2)-n.bit_count() # Chai Wah Wu, Jul 12 2022
    
  • Sage
    A120738 = lambda n: 4*n - sum(n.digits(2))
    print([A120738(n) for n in (0..58)]) # Peter Luschny, Nov 06 2016
    

Formula

a(n) = log_2(16^n/A001316(n)). [This was the original definition.]
a(n) = 2n + A005187(n).
a(n) = 3n + A011371(n).
a(n) = 4n - log_2(A001316(n)).
a(n) = log_2(A061549(n)).
2^a(n) = 16^n/A001316(n) = A061549(n).
a(n) = A086343(n) + A001511(n) for n>0. - Alford Arnold, Mar 23 2009
2^a(n) = abs(A067624(n)/A117972(n)). - Johannes W. Meijer, Jul 06 2009
a(n) = Sum_{k>=0} (A030308(n,k)*A000225(k+2)). - Philippe Deléham, Oct 16 2011
a(n) = A005187(2n). - M. F. Hasler, Jan 22 2015

Extensions

Definition simplified by M. F. Hasler, Dec 29 2012

A159885 For n >= 1, let f(2n+1) = (3n+2)/A006519(3n+2) and let f^k be the k-th iteration of f. Then a(n) is the least k such that A000120(f^k(2n+1)) <= A000120(n).

Original entry on oeis.org

2, 1, 2, 6, 1, 1, 2, 3, 3, 1, 1, 4, 1, 1, 2, 8, 2, 3, 3, 39, 1, 1, 1, 4, 3, 1, 1, 2, 1, 1, 2, 8, 5, 2, 2, 41, 3, 2, 3, 5, 5, 1, 1, 1, 1, 1, 1, 42, 2, 1, 4, 6, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 2, 44, 5, 5, 5, 31, 5, 2, 2, 41, 7, 1, 3, 3, 3, 2, 3, 34, 3, 5, 13, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 42, 8, 1, 2, 4, 1
Offset: 1

Views

Author

Vladimir Shevelev, Apr 25 2009, Apr 27 2009

Keywords

Comments

Conjecture: a(n) exists for every n >= 1. It is easy to see that this conjecture is equivalent to the well-known Collatz 3x+1 conjecture.

Crossrefs

Programs

  • PARI
    A006519(n) = (1<A006519((3*((n-1)/2))+2); \\ Defined only for odd n. Cf. A075677.
    A159885(n) = { my(w=hammingweight(n), n = (n+n+1)); for(k=1,oo,n = f(n); if(hammingweight(n) <= w, return(k))); }; \\ Antti Karttunen, Sep 22 2018

Extensions

Edited by N. J. A. Sloane, May 03 2009
a(25) corrected, sequence extended by R. J. Mathar, May 15 2009

A159945 Let f be defined as in A159885. Then a(n) = max{A000120(f^i(2n+1)): 1 <= i <= A159885(n)}.

Original entry on oeis.org

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

Views

Author

Vladimir Shevelev, Apr 27 2009

Keywords

Comments

Problem: find an upper estimate for a(n).

Crossrefs

Programs

  • PARI
    A006519(n) = (1<A006519((3*((n-1)/2))+2); \\ Defined for odd n only. Cf. A075677.
    A159945(n) = { my(w=hammingweight(n), m = 0, n = (n+n+1)); for(k=1,oo,n = f(n); m = max(m,hammingweight(n)); if(hammingweight(n) <= w, return(m))); }; \\ Antti Karttunen, Sep 22 2018

Extensions

More terms from Antti Karttunen, Sep 22 2018

A227643 a(0)=1; for n > 0, a(n) = 1 + Sum_{i=A228086(n)..A228087(n)} [A092391(i) = n]*a(i), where [] is the Iverson bracket, resulting in 1 when i + A000120(i) = n and 0 otherwise.

Original entry on oeis.org

1, 1, 2, 3, 1, 5, 1, 6, 2, 3, 7, 4, 8, 1, 13, 1, 2, 16, 1, 18, 2, 1, 21, 1, 2, 22, 3, 2, 23, 4, 1, 26, 1, 6, 2, 7, 29, 1, 37, 1, 2, 38, 3, 2, 39, 4, 1, 42, 1, 5, 3, 1, 48, 4, 1, 50, 1, 5, 2, 2, 51, 6, 3, 1, 54, 55, 7, 59, 8, 2, 68, 1, 3, 69, 4, 2, 70, 5, 1, 73, 1
Offset: 0

Views

Author

Andres M. Torres, Jul 18 2013

Keywords

Comments

Each a(n) = 1 + the count of nodes in the finite subtree defined by the edge relation parent = child + A000120(child). In other words, one more than the count of n's descendants, by which we mean the whole transitive closure of all children emanating from the parent at n. The subtree is finite because successive descendant values get smaller and approach zero.

Examples

			0 has no children distinct from itself (we only have A092391(0)=0), so we define a(0) = (0+1) = 1,
1 has no children (it is one of the terms of A010061), so a(1) = (0+1) = 1,
4 and 6 are also members of A010061, so both a(4) and a(6) = (0+1) = 1,
7 has 1,2,3,4 and 5 among its descendants (as A092391(5)=7, A092391(3)=A092391(4)=5, A092391(2)=3, A092391(1)=2), so a(7) = (5+1) = 6,
8 has 6 as a child value,        so a(8) = (1+1) = 2,
9 has 6 and 8 as descendants,    so a(9) = (2+1) = 3,
10 has {1,2,3,4,5,7}             so a(10) = (6+1) = 7.
		

Crossrefs

Cf. A010061 (gives the positions of ones), A000120, A092391, A228082, A228083, A228085, A227359, A227361, A227408.
Cf. also A213727 for a descendant counts for a similar tree defined by the edge relation parent = child - A000120(child).

Programs

  • Scheme
    ;; A deficient definition which works only up to n=128:
    (definec (A227643deficient n) (cond ((zero? n) 1) ((zero? (A228085 n)) 1) ((= 1 (A228085 n)) (+ 1 (A227643deficient (A228086 n)))) ((= 2 (A228085 n)) (+ 1 (A227643deficient (A228086 n)) (A227643deficient (A228087 n)))) (else (error "Not yet implemented for cases where n has more than two immediate children!"))))
    ;; Another definition that works for all n, but is somewhat slower:
    (definec (A227643full n) (cond ((zero? n) 1) (else (+ 1 (add (lambda (i) (if (= (A092391 i) n) (A227643full i) 0)) (A228086 n) (A228087 n))))))
    ;; Auxiliary function add implements sum_{i=lowlim..uplim} intfun(i)
    (define (add intfun lowlim uplim) (let sumloop ((i lowlim) (res 0)) (cond ((> i uplim) res) (else (sumloop (1+ i) (+ res (intfun i)))))))
    ;; by Antti Karttunen, Aug 16 2013, macro definec can be found in his IntSeq-library.

Formula

From Antti Karttunen, Aug 16 2013: (Start)
a(0)=1; and for n > 0, if A228085(n)=0 then a(n)=1; if A228085(n)=1 then a(n)=1+a(A228086(n)); if A228085(n)=2 then a(n)=1+a(A228086(n))+a(A228087(n)); otherwise (when A228085(n)>2) cannot be computed with this formula, which works only up to n=128.
a(0)=1; and for n > 0, a(n) = 1+Sum_{i=A228086(n)..A228087(n)} [A092391(i) = n]*a(i). (Here [...] denotes the Iverson bracket, resulting in 1 when i+A000120(i) = n and 0 otherwise. This formula works with all n.) (End)
Previous Showing 31-40 of 2056 results. Next