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

A160530 Positive integers that contain only odd-length runs of 0's and 1's in their binary expansion.

Original entry on oeis.org

1, 2, 5, 7, 8, 10, 14, 17, 21, 23, 29, 31, 32, 34, 40, 42, 46, 56, 58, 62, 65, 69, 71, 81, 85, 87, 93, 95, 113, 117, 119, 125, 127, 128, 130, 136, 138, 142, 160, 162, 168, 170, 174, 184, 186, 190, 224, 226, 232, 234, 238, 248, 250, 254, 257, 261, 263, 273, 277, 279
Offset: 1

Views

Author

Leroy Quet, May 17 2009

Keywords

Comments

Let the binary representation of n be thought of as a string of 0's and 1's. By a "run" of 0's or 1's, it is meant either a contiguous substring all of 0's bounded by 1's or the by the edge of the string, or a contiguous substring all of 1's bounded by 0's or the by the edge of the string.
Also, the indices of the compositions that have only odd parts. For the definition of the index of a composition see A298644. For example, 263 is in the sequence since its binary form is 100000111 and the composition [1,5,3] has only odd parts. 132 is not in the sequence since its binary form is 10000100 and the composition [1,4,1,2] also has even parts. The command c(n) from the Maple program yields the composition having index n. - Emeric Deutsch, Jan 26 2018
From Robert Israel, Jan 26 2018: (Start)
An even number n is in the sequence if and only if n = 2^k*m where k is odd and m is an odd number in the sequence.
An odd number n is in the sequence if and only if n = 2^k*(m+1)-1 where k is odd and m is 0 or an even number in the sequence. (End)

Crossrefs

Programs

  • Maple
    Runs := proc (L) local j, r, i, k: j := 1; r[j] := L[1]: for i from 2 to nops(L) do if L[i] = L[i-1] then r[j] := r[j], L[i] else j := j+1: r[j] := L[i] end if end do: [seq([r[k]], k = 1 .. j)] end proc: RunLengths := proc (L) map(nops, Runs(L)) end proc: c := proc (n) ListTools:-Reverse(convert(n, base, 2)): RunLengths(%) end proc: A := {}: for n to 280 do if type(product(c(n)[j], j = 1 .. nops(c(n))), odd) = true then A := `union`(A, {n}) else  end if end do: A; # most of the Maple program is due to W. Edwin Clark. - Emeric Deutsch, Jan 26 2018
    # Alternative:
    filter:= proc(n) option remember; local t;
    if n::even then
      t:= padic:-ordp(n,2);
      if t::even then return false fi;
      procname(n/2^t)
    else
      t:= padic:-ordp(n+1,2);
      if t::even then return false fi;
      procname((n+1)/2^t-1)
      fi
    end proc:
    filter(0):= true:
    select(filter, [$1..1000]); # Robert Israel, Jan 26 2018
  • Mathematica
    Select[Range[300],And@@OddQ/@Length/@Split[IntegerDigits[ #,2]]&] (* Ray Chandler, May 19 2009 *)
  • Python
    from itertools import groupby
    def ok(n): return all(len(list(g))%2 == 1 for k, g in groupby(bin(n)[2:]))
    print([i for i in range(1, 280) if ok(i)]) # Michael S. Branicky, Jan 04 2021

Extensions

Extended by Ray Chandler, May 19 2009

A322149 In the binary representation of n, replace each run of k 0's (or 1's) with k^2 0's (or 1's).

Original entry on oeis.org

0, 1, 2, 15, 16, 5, 30, 511, 512, 33, 10, 47, 240, 61, 1022, 65535, 65536, 1025, 66, 271, 80, 21, 94, 1535, 7680, 481, 122, 495, 8176, 2045, 131070, 33554431, 33554432, 131073, 2050, 8207, 528, 133, 542, 8703, 2560, 161, 42, 175, 752, 189, 3070, 196607, 983040
Offset: 0

Views

Author

Rémy Sigrist, Nov 28 2018

Keywords

Comments

This sequence has similarities with A001196: here we square the length of each run of consecutive equal bits, there we double it.

Crossrefs

Programs

  • Mathematica
    squareList[v_] := Flatten[ConstantArray[v, {Length[v]}]]; a[n_] := FromDigits[ Flatten[squareList /@ Split[IntegerDigits[n, 2]]], 2]; Array[a, 60, 0] (* Amiram Eldar, Dec 07 2018*)
  • PARI
    a(n) = if (n==0, 0, my (b=n%2, k=valuation(n+b,2)); (a(n\2^k) + b) * 2^(k^2) - b)

Formula

a(n) = A322403(n, n).
a(n) >= n with equality iff n belongs to A000975.
a(2^n) = 2^(n^2) for any n >= 0.
a(2^n - 1) = 2^(n^2) - 1 for any n >= 0.
A005811(a(n)) = A005811(n).

A322403 Square array T(n, k) read by antidiagonals, n >= 0 and k >= 0: the lengths of runs in binary expansion of T(n, k) are obtained by multiplying those of n and of k (see Comments for precise definition).

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 0, 2, 2, 0, 0, 3, 2, 3, 0, 0, 4, 12, 12, 4, 0, 0, 5, 4, 15, 4, 5, 0, 0, 6, 42, 48, 48, 42, 6, 0, 0, 7, 6, 51, 16, 51, 6, 7, 0, 0, 8, 56, 60, 292, 292, 60, 56, 8, 0, 0, 9, 8, 63, 12, 5, 12, 63, 8, 9, 0, 0, 10, 150, 192, 448, 438, 438, 448, 192
Offset: 0

Views

Author

Rémy Sigrist, Dec 06 2018

Keywords

Comments

For any n >= 0 and k >= 0:
- let r_n be the lengths of runs in binary expansion of n,
- for n = 0: we assume that r_0 = (),
- when n > 0: let R_n be the #r_n-periodic sequence whose first #r_n terms match r_n,
- r_{T(n, k)} has lcm(#r_n, #r_k) terms and r_{T(n, k)}(i) = R_n(i) * R_k(i) for i = 1..lcm(#r_n, #r_k).

Examples

			Array T(n, k) begins (in decimal):
  n\k|  0  1   2    3    4     5    6     7     8     9     10
  ---+--------------------------------------------------------
    0|  0  0   0    0    0     0    0     0     0      0     0
    1|  0  1   2    3    4     5    6     7     8      9    10
    2|  0  2   2   12    4    42    6    56     8    150    10
    3|  0  3  12   15   48    51   60    63   192    195   204
    4|  0  4   4   48   16   292   12   448    64   2124    36
    5|  0  5  42   51  292     5  438   455  2184      9  2730
    6|  0  6   6   60   12   438   30   504    24   3294    54
    7|  0  7  56   63  448   455  504   511  3584   3591  3640
    8|  0  8   8  192   64  2184   24  3584   512  33048   136
Array T(n, k) begins (in binary):
   n\k|  0     1      10        11        100          101         110
  ----+---------------------------------------------------------------
     0|  0     0       0         0          0             0          0
     1|  0     1      10        11        100           101        110
    10|  0    10      10      1100        100        101010        110
    11|  0    11    1100      1111     110000        110011     111100
   100|  0   100     100    110000      10000     100100100       1100
   101|  0   101  101010    110011  100100100           101  110110110
   110|  0   110     110    111100       1100     110110110      11110
   111|  0   111  111000    111111  111000000     111000111  111111000
  1000|  0  1000    1000  11000000    1000000  100010001000      11000
		

Crossrefs

See A322404 for the additive variant.

Programs

  • PARI
    T(n,k) = my (v=0, p=1, rn=n, rk=k, b=if ((max(n,1)%2)&&(max(k,1)%2), 1, 0)); while (1, my (vn=if (rn==0, 0, valuation(rn+(rn%2), 2)), vk=if(rk==0, 0, valuation(rk+(rk%2), 2)), w=vn*vk); v+=b*p*(2^w-1); rn\=2^vn; rk\=2^vk; if (rn==0 && rk==0, return (v), rn==0, rn=n, rk==0, rk=k); p*=2^w; b=1-b)

Formula

For any m >= 0, n >= 0 and k >= 0:
- T(n, k) = T(k, n) (T is commutative),
- T(m, T(n, k)) = T(T(m, n), k) (T is associative),
- T(m, A322404(n, k)) = A322404(T(m, n), T(m, k)) (T distributes over A322404),
- T(n, 0) = 0 (0 is an absorbing element for T),
- T(n, 1) = n (1 is an neutral element for T),
- T(n, 3) = A001196(n),
- T(n, 7) = A097254(n+1),
- T(n, 15) = A097262(n),
- T(n, n) = A322149(n),
- A005811(T(n, k)) = lcm(A005811(n), A005811(k)),
- T(2^n - 1, 2^k - 1) = 2^(n*k) - 1.
- T(2^n, 2^k) = 2^(n*k) when n > 0 and k > 0,
- T(n, k) is odd iff both n and k are odd.

A329101 Lexicographically earliest sequence of distinct nonnegative integers such that for any n >= 0, the number of 1's in the base 4 expansion of n equals the number of 2's in the base 4 expansion of a(n).

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Nov 07 2019

Keywords

Comments

This sequence is a permutation of the nonnegative integers with inverse A329180.
Apparently, fixed points correspond to A001196.
The sequence has fractal features; for any k >= 0, the set of points { (n, a(n)), n = 0..4^k-1 } is symmetrical relative to the line of equation y + x = 4^k - 1 (see scatterplots in Links section).

Examples

			The first terms, alongside the base 4 representations of n and of a(n), are:
  n   a(n)  qua(n)  qua(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     2       1          2
   2     1       2          1
   3     3       3          3
   4     6      10         12
   5    10      11         22
   6     8      12         20
   7     9      13         21
   8     4      20         10
   9    11      21         23
  10     5      22         11
  11     7      23         13
  12    12      30         30
  13    14      31         32
  14    13      32         31
  15    15      33         33
		

Crossrefs

Programs

  • PARI
    See Links section.

Formula

A160381(n) = A160382(a(n)).

A345352 The binary expansion of a(n) is obtained by left-padding the binary expansion of n with 0's so that it has 2^k digits for some k > 0 as small as possible and then reversing the first half and the second half of this binary expansion.

Original entry on oeis.org

0, 1, 2, 3, 8, 10, 9, 11, 4, 6, 5, 7, 12, 14, 13, 15, 128, 136, 132, 140, 130, 138, 134, 142, 129, 137, 133, 141, 131, 139, 135, 143, 64, 72, 68, 76, 66, 74, 70, 78, 65, 73, 69, 77, 67, 75, 71, 79, 192, 200, 196, 204, 194, 202, 198, 206, 193, 201, 197, 205
Offset: 0

Views

Author

Rémy Sigrist, Jun 15 2021

Keywords

Comments

This sequence is a self-inverse permutation of the nonnegative integers with infinitely many fixed points (A345362).

Examples

			For n = 43:
- the binary expansion of n is "101011",
- it has 6 binary digits, so we pad it with 2 leading 0's,
- the first half is "0010" and its reversal is "0100",
- the second half is "1011" and its reversal is "1101",
- so the binary expansion of a(43) is "01001101",
- and a(43) = 77.
		

Crossrefs

Cf. A000120, A001196, A054429, A345362 (fixed points).

Programs

  • PARI
    a(n) = { my (b=binary(n), x); for (k=1, oo, x=2^k-#b; if (x>=0, b=concat(vector(x), b); return (fromdigits(concat(Vecrev(b[1..#b/2]), Vecrev(b[#b/2+1..#b])), 2)))) }
    
  • Python
    def a(n):
        b = bin(n)[2:]
        bb = bin(len(b))[2:]
        if bb != '1' + '0'*(len(bb)-1): b = '0'*(2**len(bb) - len(b)) + b
        return int(b[:len(b)//2][::-1] + b[len(b)//2:][::-1], 2)
    print([a(n) for n in range(60)]) # Michael S. Branicky, Jun 15 2021

Formula

A000120(a(n)) = A000120(n).
a(A001196(n)) = A001196(a(n)).
a(n) < 2^2^k for any n < 2^2^k.
a(2^k) = 2^A054429(k) for any k > 0.

A345362 Fixed points of A345352.

Original entry on oeis.org

0, 1, 2, 3, 12, 15, 96, 102, 105, 111, 144, 150, 153, 159, 240, 246, 249, 255, 6144, 6168, 6180, 6204, 6210, 6234, 6246, 6270, 6273, 6297, 6309, 6333, 6339, 6363, 6375, 6399, 9216, 9240, 9252, 9276, 9282, 9306, 9318, 9342, 9345, 9369, 9381, 9405, 9411, 9435
Offset: 1

Views

Author

Rémy Sigrist, Jun 16 2021

Keywords

Comments

The binary expansion of a term > 1 can be split into two symmetrical parts of the same size (this size being a power of 2) (possibly after adjoining some leading 0's), and the first part contains at least one 1.
If m is a term, then A001196(m) is also a term.

Examples

			A345352(96) = 96, so 96 belongs to this sequence.
		

Crossrefs

Programs

  • PARI
    is(n) = { my (b=binary(n), x); for (k=1, oo, x=2^k-#b; if (x>=0, b=concat(vector(x), b); return (n==fromdigits(concat(Vecrev(b[1..#b/2]), Vecrev(b[#b/2+1..#b])), 2)))) }
    
  • PARI
    See Links section.
    
  • Python
    def A345352(n):
        b = bin(n)[2:]
        bb = bin(len(b))[2:]
        if bb != '1' + '0'*(len(bb)-1): b = '0'*(2**len(bb) - len(b)) + b
        return int(b[:len(b)//2][::-1] + b[len(b)//2:][::-1], 2)
    def ok(n): return A345352(n) == n
    print(list(filter(ok, range(9436))))  # Michael S. Branicky, Jun 16 2021

A356352 a(n) = GCD of run lengths in binary expansion of n.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Oct 15 2022

Keywords

Comments

a(0) = 0 as the GCD of an empty list (we consider here that the binary expansion of 0 has no runs).

Crossrefs

Programs

  • Mathematica
    {0}~Join~Array[GCD @@ Map[Length, Split@ IntegerDigits[#, 2]] &, 104] (* Michael De Vlieger, Oct 17 2022 *)
  • PARI
    a(n) = { my (r=[]); while (n, my (v=valuation(n+n%2, 2)); n\=2^v; r=concat(v, r)); gcd(r) }
    
  • Python
    from math import gcd
    from itertools import groupby
    def a(n):
        if n == 0: return 0 # by convention
        return gcd(*(len(list(g)) for k, g in groupby(bin(n)[2:])))
    print([a(n) for n in range(87)]) # Michael S. Branicky, Oct 15 2022

Formula

a(A001196(n)) = 2*a(n).
a(2^k-1) = k for any k >= 0.

A160531 Those positive integers n that contain both odd-lengthed and even-lengthed runs of 0's and 1's when n is represented in binary.

Original entry on oeis.org

4, 6, 9, 11, 13, 16, 18, 19, 20, 22, 24, 25, 26, 27, 28, 30, 33, 35, 36, 37, 38, 39, 41, 43, 44, 45, 47, 49, 50, 52, 53, 54, 55, 57, 59, 61, 64, 66, 67, 68, 70, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 86, 88, 89, 90, 91, 92, 94, 96, 97, 98, 99, 100, 101, 102, 103, 104
Offset: 1

Views

Author

Leroy Quet, May 17 2009

Keywords

Comments

Let the binary representation of n be thought of as a string of 0's and 1's. By a "run" of 0's or 1's, it is meant either a contiguous substring all of 0's bounded by 1's or the by the edge of the string, or a contiguous substring all of 1's bounded by 0's or the by the edge of the string.
This sequence contains precisely those positive integers that are in neither sequence A001196 nor sequence A160530.

Crossrefs

Programs

  • Mathematica
    Select[Range[120],Select[l=Length/@Split[IntegerDigits[ #,2]],EvenQ]!={}&&Select[l,OddQ]!={}&] (* Ray Chandler, May 19 2009 *)

Extensions

Extended by Ray Chandler, May 19 2009

A322404 Square array T(n, k) read by antidiagonals, n >= 0 and k >= 0: the lengths of runs in binary expansion of T(n, k) are obtained by adding those of n and of k (see Comments for precise definition).

Original entry on oeis.org

0, 1, 1, 2, 3, 2, 3, 12, 12, 3, 4, 7, 12, 7, 4, 5, 24, 56, 56, 24, 5, 6, 51, 24, 15, 24, 51, 6, 7, 28, 3276, 112, 112, 3276, 28, 7, 8, 15, 28, 455, 48, 455, 28, 15, 8, 9, 48, 240, 120, 25368, 25368, 120, 240, 48, 9, 10, 99, 48, 31, 56, 51, 56, 31, 48, 99, 10
Offset: 0

Views

Author

Rémy Sigrist, Dec 06 2018

Keywords

Comments

For any n >= 0 and k >= 0:
- let r_n be the lengths of runs in binary expansion of n,
- for n = 0: we assume that r_0 = (0),
- let R_n be the #r_n-periodic sequence whose first #r_n terms match r_n,
- r_{T(n, k)} has lcm(#r_n, #r_k) terms and r_{T(n, k)}(i) = R_n(i) + R_k(i) for i = 1..lcm(#r_n, #r_k).

Examples

			Array T(n, k) begins (in decimal):
  n\k|  0   1     2    3      4       5      6     7       8       9        10
  ---+------------------------------------------------------------------------
    0|  0   1     2    3      4       5      6     7       8       9        10
    1|  1   3    12    7     24      51     28    15      48      99       204
    2|  2  12    12   56     24    3276     28   240      48   12700       204
    3|  3   7    56   15    112     455    120    31     224     903      3640
    4|  4  24    24  112     48   25368     56   480      96   99896       792
    5|  5  51  3276  455  25368      51  29596  3855  199728      99  13421772
    6|  6  28    28  120     56   29596     60   496     112  116540       924
    7|  7  15   240   31    480    3855    496    63     960    7695     61680
    8|  8  48    48  224     96  199728    112   960     192  792688      3120
Array T(n, k) begins (in binary):
   n\k|     0       1            10         11              100
  ----+--------------------------------------------------------
     0|     0       1            10         11              100
     1|     1      11          1100        111            11000
    10|    10    1100          1100     111000            11000
    11|    11     111        111000       1111          1110000
   100|   100   11000         11000    1110000           110000
   101|   101  110011  110011001100  111000111  110001100011000
   110|   110   11100         11100    1111000           111000
   111|   111    1111      11110000      11111        111100000
  1000|  1000  110000        110000   11100000          1100000
		

Crossrefs

See A322403 for the multiplicative variant.

Programs

  • PARI
    T(n,k) = my (v=0, p=1, rn=n, rk=k, b=if ((max(n,1)%2)&&(max(k,1)%2), 1, 0)); while (1, my (vn=if (rn==0, 0, valuation(rn+(rn%2), 2)), vk=if(rk==0, 0, valuation(rk+(rk%2), 2)), w=vn+vk); v+=b*p*(2^w-1); rn\=2^vn; rk\=2^vk; if (rn==0 && rk==0, return (v), rn==0, rn=n, rk==0, rk=k); p*=2^w; b=1-b)

Formula

For any m >= 0, n >= 0 and k >= 0:
- T(n, k) = T(k, n) (T is commutative),
- T(m, T(n, k)) = T(T(m, n), k) (T is associative),
- T(n, 0) = n (0 is a neutral element for T),
- T(n, 1) = A175046(n),
- T(n, n) = A001196(n),
- A005811(T(n, k)) = max(A005811(n), A005811(k), lcm(A005811(n), A005811(k))),
- T(2^n - 1, 2^k - 1) = 2^(n+k) - 1,
- T(2^n, 2^k) = 3 * 2^(n+k) when n > 0 and k > 0,
- T(n, k) is odd iff both n and k are odd.

A325055 a(0) = 0, a(1) = 1; a(2*n) = a(n-1) + a(n), a(2*n+1) = a(n+1) - a(n).

Original entry on oeis.org

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

Views

Author

Ilya Gutkovskiy, Sep 04 2019

Keywords

Crossrefs

Cf. A001196 (positions of 0's), A002487, A005590, A075825.

Programs

  • Mathematica
    a[0] = 0; a[1] = 1; a[n_] := a[n] = If[EvenQ[n], a[(n - 2)/2] + a[n/2], a[(n + 1)/2] - a[(n - 1)/2]]; Table[a[n], {n, 0, 75}]

Formula

a(n) = Sum_{k=1..n} a(2*k-1) = Sum_{k=1..n} (-1)^(n-k) * a(2*k).
a(2^k) = 2^floor(k/2).
Previous Showing 31-40 of 46 results. Next