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 21-29 of 29 results.

A345927 Alternating sum of the binary expansion of n (row n of A030190). Replace 2^k with (-1)^(A070939(n)-k) in the binary expansion of n (compare to the definition of A065359).

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Jul 14 2021

Keywords

Comments

The alternating sum of a sequence (y_1,...,y_k) is Sum_i (-1)^(i-1) y_i.

Examples

			The binary expansion of 53 is (1,1,0,1,0,1), so a(53) = 1 - 1 + 0 - 1 + 0 - 1 = -2.
		

Crossrefs

Binary expansions of each nonnegative integer are the rows of A030190.
The positions of 0's are A039004.
The version for prime factors is A071321 (reverse: A071322).
Positions of first appearances are A086893.
The version for standard compositions is A124754 (reverse: A344618).
The version for prime multiplicities is A316523.
The version for prime indices is A316524 (reverse: A344616).
A003714 lists numbers with no successive binary indices.
A070939 gives the length of an integer's binary expansion.
A103919 counts partitions by sum and alternating sum.
A328594 lists numbers whose binary expansion is aperiodic.
A328595 lists numbers whose reversed binary expansion is a necklace.

Programs

  • Mathematica
    ats[y_]:=Sum[(-1)^(i-1)*y[[i]],{i,Length[y]}];
    Table[ats[IntegerDigits[n,2]],{n,0,100}]
  • PARI
    a(n) = subst(Pol(Vecrev(binary(n))), x, -1); \\ Michel Marcus, Jul 19 2021
    
  • Python
    def a(n): return sum((-1)**k for k, bi in enumerate(bin(n)[2:]) if bi=='1')
    print([a(n) for n in range(84)]) # Michael S. Branicky, Jul 19 2021

Formula

a(n) = (-1)^(A070939(n)-1)*A065359(n).

A320441 Numbers whose binary expansion is quasiperiodic.

Original entry on oeis.org

3, 7, 10, 15, 21, 31, 36, 42, 45, 54, 63, 73, 85, 91, 109, 127, 136, 146, 153, 170, 173, 181, 182, 187, 204, 219, 221, 238, 255, 273, 292, 307, 341, 365, 375, 409, 438, 443, 477, 511, 528, 546, 561, 585, 594, 614, 627, 660, 682, 685, 693, 725, 726, 731, 750
Offset: 1

Views

Author

Rémy Sigrist, Jan 09 2019

Keywords

Comments

The binary representation of a term (ignoring leading zeros) can be covered by (possibly overlapping) occurrences of one of its proper prefix.
This sequence contains A121016.
For any k > 0, there are A320434(k)/2 terms with binary length k.

Examples

			The first terms, alongside their binary representations and prefixes, are:
  n   a(n)  bin(a(n))  prefix
  --  ----  ---------  ------
   1     3         11       1
   2     7        111       1
   3    10       1010      10
   4    15       1111       1
   5    21      10101     101
   6    31      11111       1
   7    36     100100     100
   8    42     101010      10
   9    45     101101     101
  10    54     110110     110
  11    63     111111       1
  12    73    1001001    1001
		

Crossrefs

Programs

  • PARI
    isok(w) = { my (tt=0); for (l=1, oo, my (t=w%(2^l)); if (t!=tt, if (t==w, return (0)); my (r=w, g=l); while (g-->=0 && r>=t, r \= 2; if (r%(2^l)==t, if (r==t, return (1), g=l))); tt = t)) }
    
  • Python
    def qp(w):
        for i in range(1, len(w)):
            prefix, covered = w[:i], set()
            for j in range(len(w)-i+1):
                if w[j:j+i] == prefix:
                    covered |= set(range(j, j+i))
            if covered == set(range(len(w))):
                return True
        return False
    def ok(n): return qp(bin(n)[2:])
    print([k for k in range(751) if ok(k)]) # Michael S. Branicky, Mar 20 2022

Formula

A020330(a(n)) belongs to the sequence for any n > 0.
A297405(a(n)) belongs to the sequence for any n > 0.

A329143 Number of integer partitions of n whose augmented differences are a periodic word.

Original entry on oeis.org

0, 0, 1, 1, 1, 2, 1, 1, 3, 2, 2, 3, 2, 2, 4, 4, 5, 3, 5, 2, 10, 5, 6, 5, 10, 5, 11, 7, 13, 6, 15, 6, 20, 11, 18, 12, 27, 8, 27, 16, 32, 14, 35, 14, 42, 23, 43, 17, 56, 17, 61, 31, 67, 25, 78, 28, 88, 41, 89, 35, 119, 39, 116, 60, 131, 52, 154, 52, 170, 75, 182
Offset: 0

Views

Author

Gus Wiseman, Nov 10 2019

Keywords

Comments

The augmented differences aug(y) of an integer partition y of length k are given by aug(y)i = y_i - y{i + 1} + 1 if i < k and aug(y)_k = y_k. For example, aug(6,5,5,3,3,3) = (2,1,3,1,1,3).
A finite sequence is periodic if its cyclic rotations are not all different.

Examples

			The a(n) partitions for n = 2, 5, 8, 14, 16, 22:
  11  32     53        95              5533              7744
      11111  3221      5432            7441              9652
             11111111  32222111        533311            554332
                       11111111111111  33222211          54333211
                                       1111111111111111  332222221111
                                                         1111111111111111111111
		

Crossrefs

The Heinz numbers of these partitions are given by A329132.
The aperiodic version is A329136.
The non-augmented version is A329144.
Periodic binary words are A152061.
Periodic compositions are A178472.
Numbers whose binary expansion is periodic are A121016.
Numbers whose prime signature is periodic are A329140.

Programs

  • Mathematica
    aperQ[q_]:=Array[RotateRight[q,#1]&,Length[q],1,UnsameQ];
    aug[y_]:=Table[If[i
    				

Formula

a(n) + A329136(n) = A000041(n).

Extensions

More terms from Jinyuan Wang, Jun 27 2020

A329144 Number of integer partitions of n whose differences are a periodic word.

Original entry on oeis.org

0, 0, 1, 1, 1, 3, 1, 2, 5, 3, 2, 8, 2, 5, 9, 7, 5, 12, 7, 7, 19, 9, 9, 21, 12, 15, 23, 18, 17, 29, 21, 19, 42, 23, 31, 42, 38, 29, 53, 43, 44, 62, 49, 52, 79, 55, 72, 75, 87, 63, 117, 79, 104, 107, 120, 99, 156, 117, 143, 147
Offset: 1

Views

Author

Gus Wiseman, Nov 10 2019

Keywords

Comments

A finite sequence is periodic if its cyclic rotations are not all different.

Examples

			The a(n) partitions for n = 3, 6, 8, 9, 12, 15, 16:
  111  222     2222      333        444           555              4444
       321     11111111  432        543           654              7531
       111111            531        642           753              44332
                         32211      741           852              3332221
                         111111111  3333          951              4332211
                                    222222        33333            22222222
                                    3222111       54321            1111111111111111
                                    111111111111  322221111
                                                  111111111111111
		

Crossrefs

The Heinz numbers of these partitions are given by A329134.
The augmented version is A329143.
Periodic binary words are A152061.
Periodic compositions are A178472.
Numbers whose binary expansion is periodic are A121016.
Numbers whose prime signature is periodic are A329140.

Programs

  • Mathematica
    aperQ[q_]:=Array[RotateRight[q,#1]&,Length[q],1,UnsameQ];
    Table[Length[Select[IntegerPartitions[n],!aperQ[Differences[#]]&]],{n,30}]

A257739 Numbers n for which A256999(n) > n; numbers that can be made larger by rotating (by one or more steps) the non-msb bits of their binary representation (with A080541 or A080542).

Original entry on oeis.org

5, 9, 10, 11, 13, 17, 18, 19, 20, 21, 22, 23, 25, 27, 29, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 53, 54, 55, 57, 59, 61, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 97, 98, 99, 101, 102, 103, 105, 107, 108, 109, 110, 111
Offset: 1

Views

Author

Antti Karttunen, May 18 2015

Keywords

Comments

Note that A256999(a(n)) is always in A257250.
If we define a co-necklace to be a finite sequence that is lexicographically maximal (not minimal) among all of its cyclic rotations, these are numbers whose binary expansion, without the most significant digit, is not a co-necklace. Numbers whose binary expansion, without the most significant digit, is not a necklace are A329367. - Gus Wiseman, Nov 14 2019

Examples

			For n = 5 with binary representation "101" if we rotate other bits than the most significant bit (that is, only the two rightmost digits "01") one step to either direction we get "110" = 6 > 5, so 5 can be made larger by such rotations and thus 5 is included in this sequence.
For n = 6 with binary representation "110" no such rotation will yield a larger number and thus 6 is NOT included in this sequence.
For n = 10 with binary representation "1010" if we rotate other bits than the most significant bit (that is, only the three rightmost digits "010") either one step to the left or two steps to the right we get "1100" = 12 > 10, thus 10 is included in this sequence.
		

Crossrefs

Complement: A257250.
Numbers whose binary expansion is a necklace are A275692.
Numbers whose binary expansion is a co-necklace are A065609.
Numbers whose reversed binary expansion is a necklace are A328595.
Numbers whose non-msb expansion is a co-necklace are A257250.
Numbers whose non-msb expansion is a necklace are A328668.
Numbers whose reversed non-msb expansion is a necklace are A328607.
Numbers whose non-msb expansion is not a necklace are A329367.
Binary necklaces are A000031.
Necklace compositions are A008965.

Programs

  • Mathematica
    reckQ[q_]:=Array[OrderedQ[{RotateRight[q,#],q}]&,Length[q]-1,1,And];
    Select[Range[2,100],!reckQ[Rest[IntegerDigits[#,2]]]&] (* Gus Wiseman, Nov 14 2019 *)

A297405 Binary "cubes"; numbers whose binary representation consists of three consecutive identical blocks.

Original entry on oeis.org

7, 42, 63, 292, 365, 438, 511, 2184, 2457, 2730, 3003, 3276, 3549, 3822, 4095, 16912, 17969, 19026, 20083, 21140, 22197, 23254, 24311, 25368, 26425, 27482, 28539, 29596, 30653, 31710, 32767, 133152, 137313, 141474, 145635, 149796, 153957, 158118, 162279, 166440, 170601, 174762, 178923, 183084, 187245
Offset: 1

Views

Author

Jeffrey Shallit, Dec 29 2017

Keywords

Comments

Alternatively, numbers of the form k*(4^n + 2^n + 1), where 2^(n-1) <= k < 2^n.

Examples

			42 in base 2 is 101010, which consists of three copies of the block "10".
		

Crossrefs

Cf. A020330, which is the corresponding sequence for squares.
Subsequence of A121016.

Programs

  • Maple
    a:= n-> (p-> n*(1+2^p+4^p))(1+ilog2(n)):
    seq(a(n), n=1..50);  # Alois P. Heinz, Dec 29 2017
  • Mathematica
    bc[n_]:=FromDigits[Join[n,n,n],2]; Flatten[Table[bc/@Select[Tuples[ {1,0},n],#[[1]] == 1&],{n,6}]]//Union (* Harvey P. Dale, Oct 09 2021 *)
  • PARI
    a(n) = n=binary(n); fromdigits(concat([n, n, n]) , 2) \\ Iain Fox, Jul 04 2022
  • Python
    def a(n): return int(bin(n)[2:]*3, 2)
    print([a(n) for n in range(1, 46)]) # Michael S. Branicky, Jul 04 2022
    # Alternative:
    def A297405(n):
        p = n.bit_length()
        return n * (1 + 2**p + 4**p)
    print([A297405(n) for n in range(1, 46)])  # Peter Luschny, Jul 05 2022
    

Formula

a(n) = n*(1 + 2^p + 4^p) with p = 1 + floor(log_2(n)). - Alois P. Heinz, Dec 29 2017
G.f.: (7*x + Sum_{n>=1} (4^n + 3*8^n + (2^n + 2*4^n - 3*8^n)*x)*x^(2^n))/(1-x)^2. - Robert Israel, Dec 31 2017

A329356 The binary expansion of a(n) is the first n terms of 2 - A000002.

Original entry on oeis.org

0, 1, 2, 4, 9, 19, 38, 77, 154, 308, 617, 1234, 2468, 4937, 9875, 19750, 39501, 79003, 158006, 316012, 632025, 1264050, 2528101, 5056203, 10112406, 20224813, 40449626, 80899252, 161798505, 323597011, 647194022, 1294388045, 2588776091, 5177552182, 10355104365
Offset: 0

Views

Author

Gus Wiseman, Nov 12 2019

Keywords

Examples

			a(7) = 77 has binary expansion q = {1, 0, 0, 1, 1, 0, 1}, and 2 - q is {1, 2, 2, 1, 1, 2, 1}, which is the first 7 terms of A000002.
		

Crossrefs

Replacing "2 - A000002" with "A000002 - 1" gives A329355.
Initial subsequences of A000002 are A329360.

Programs

  • Mathematica
    kolagrow[q_]:=If[Length[q]<2,Take[{1,2},Length[q]+1],Append[q,Switch[{q[[Length[Split[q]]]],q[[-2]],Last[q]},{1,1,1},0,{1,1,2},1,{1,2,1},2,{1,2,2},0,{2,1,1},2,{2,1,2},2,{2,2,1},1,{2,2,2},1]]]
    kol[n_Integer]:=If[n==0,{},Nest[kolagrow,{1},n-1]];
    Table[FromDigits[2-kol[n],2],{n,0,30}]

Formula

a(n) = floor((1-c/2)*2^n), where c = A118270 is the Kolakoski constant. - Lorenzo Sauras Altuzarra, Jan 01 2023

A306595 Determinant of the circulant matrix whose first column corresponds to the binary digits of n.

Original entry on oeis.org

0, 1, 1, 0, 1, 2, 2, 0, 1, 0, 0, 3, 0, -3, 3, 0, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 0, 1, 0, 4, 0, 0, -9, 9, 0, 4, 9, 0, 8, 9, 0, 8, 5, 0, 0, 9, 0, -9, -8, 0, -5, 0, 0, 8, 5, 0, -5, 5, 0, 1, 2, 2, 3, 2, 24, 24, 4, 2, 3, 3, 32, 3, 4, 32, 5, 2, 24, 3
Offset: 0

Views

Author

Rémy Sigrist, Feb 27 2019

Keywords

Comments

This sequence is the binary variant of A177894.
From Robert Israel, Mar 05 2019: (Start)
a(n) is divisible by A000120(n).
If A070939(n) is even then n is divisible by A000120(n)*A065359(n). (End)

Examples

			For n = 13:
- the binary representation of 13 is "1101",
- the corresponding circulant matrix is:
    [1 1 0 1]
    [1 1 1 0]
    [0 1 1 1]
    [1 0 1 1]
- its determinant is -3,
- hence a(13) = -3.
		

Crossrefs

Programs

  • Maple
    a:= n-> `if`(n=1, 1, (l-> LinearAlgebra[Determinant](Matrix(nops(l),
           shape=Circulant[l[-i]$i=1..nops(l)])))(convert(n, base, 2))):
    seq(a(n), n=0..100);  # Alois P. Heinz, Mar 05 2019
  • PARI
    a(n) = my (d=if (n, binary(n), [0])); my (m=matrix(#d, #d, i,j, d[1+(i-j)%#d])); return (matdet(m))

Formula

a(A121016(n)) = 0 for any n > 0.
a(2^k) = 1 for any k >= 0.
a(A219325(n)) = A219325(n) for any n > 0.

A353339 Number of integers b with n > b > 1 such that the base-b representation of n is periodic.

Original entry on oeis.org

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

Views

Author

Felix Fröhlich, Apr 14 2022

Keywords

Examples

			For n = 10: The base-2, base-3, base-4 and base-9 representations of 10 are 1010, 0101, 22 and 11, respectively, and these are the only representations that are periodic, so a(10) = 4.
		

Crossrefs

Programs

  • PARI
    is(n, b) = for (w=1, oo, my (d=digits(n, b^w)); if (#d<=1, return (0), #Set(d)==1, return (1))) \\ after Rémy Sigrist in A321513
    a(n) = my(i=0); for(b=2, n-1, if(is(n, b), i++)); i
Previous Showing 21-29 of 29 results.