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-30 of 64 results. Next

A044918 Positive integers whose base-2 run lengths form a palindrome.

Original entry on oeis.org

1, 2, 3, 5, 7, 9, 10, 12, 15, 17, 21, 27, 31, 33, 38, 42, 45, 51, 52, 56, 63, 65, 73, 85, 93, 99, 107, 119, 127, 129, 142, 150, 153, 165, 170, 178, 189, 195, 204, 212, 219, 231, 232, 240, 255, 257, 273, 297, 313, 325, 341, 365, 381
Offset: 1

Views

Author

Keywords

Comments

This sequence exactly contains those positive integers in A006995 (positive binary palindromes) together with the terms of A035928 (those positive integers n where reversing the order of the binary digits produces the binary complement of n). - Leroy Quet, Sep 14 2009
Also the indices of the compositions that are palindromic. For the definition of the index of a composition see A298644. For example, 93 is in the sequence since its binary form is 1011101 and the composition [1,1,3,1,1] is palindromic. On the other hand, 132 is not in the sequence since its binary form is 10000100 and the composition [1,4,1,2] is not palindromic. The command c(n) from the Maple program yields the composition having index n. - Emeric Deutsch, Jan 28 2018

Crossrefs

Cf. A006995, A035928. - Leroy Quet, Sep 14 2009
Cf. A298644, A101211. - Emeric Deutsch, Jan 28 2018

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 from 1 to 500 do crev(n):=[seq(c(n)[1+ nops(c(n))-j],j=1..nops(c(n)))] od:  for n from 1 to 500 do if c(n)=crev(n) then A:=A union {n} else fi od: A; # most of the Maple program is due to W. Edwin Clark. # Emeric Deutsch, Jan 28 2018
  • Mathematica
    Position[Array[Length /@ Split@ IntegerDigits[#, 2] &, 400], ? PalindromeQ, 1] // Flatten (* _Michael De Vlieger, Jan 28 2018 *)
  • PARI
    ispal(v) = {for(i=1, #v\2, if (v[i] != v[#v-i+1], return(0));); return(1);}
    isok(n) = {b = binary(n); lastb = b[1]; vrun = vector(1); vrun[1] = 1; for (i=2, #b, if (b[i] != lastb, vrun = concat(vrun, 1); lastb = b[i];, vrun[#vrun]++;)); return (ispal(vrun));} \\ Michel Marcus, Jul 10 2013

A296656 Triangle whose n-th row is the concatenated sequence of all Lyndon compositions of n in reverse-lexicographic order.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Dec 18 2017

Keywords

Examples

			Triangle of Lyndon compositions begins:
(1),
(2),
(3),(12),
(4),(13),(112),
(5),(23),(14),(122),(113),(1112),
(6),(24),(15),(132),(123),(114),(1122),(1113),(11112),
(7),(34),(25),(223),(16),(142),(133),(124),(1222),(1213),(115),(1132),(1123),(11212),(1114),(11122),(11113),(111112).
		

Crossrefs

Programs

  • Mathematica
    LyndonQ[q_]:=Array[OrderedQ[{q,RotateRight[q,#]}]&,Length[q]-1,1,And]&&Array[RotateRight[q,#]&,Length[q],1,UnsameQ];
    Table[Sort[Select[Join@@Permutations/@IntegerPartitions[n],LyndonQ],OrderedQ[PadRight[{#2,#1}]]&],{n,7}]

Formula

Row n is a concatenation of A059966(n) Lyndon words with total length A000740(n).

A318927 Take the binary expansion of n, starting with the most significant bit, and concatenate the lengths of the runs.

Original entry on oeis.org

1, 11, 2, 12, 111, 21, 3, 13, 121, 1111, 112, 22, 211, 31, 4, 14, 131, 1211, 122, 1112, 11111, 1121, 113, 23, 221, 2111, 212, 32, 311, 41, 5, 15, 141, 1311, 132, 1212, 12111, 1221, 123, 1113
Offset: 1

Views

Author

N. J. A. Sloane, Sep 09 2018

Keywords

Comments

Obviously this compressed notation is useful only for n < 1023. A101211 is a version which works for all n.

Examples

			n, binary, run lengths, -> a(n)
1, [1], [1] -> 1
2, [1, 0], [1, 1] -> 11
3, [1, 1], [2] -> 2
4, [1, 0, 0], [1, 2] -> 12
5, [1, 0, 1], [1, 1, 1] -> 111
6, [1, 1, 0], [2, 1] -> 21
7, [1, 1, 1], [3] -> 3
...
		

Crossrefs

Cf. A101211 (without concatenation, as rows), A227736 (rows reversed), A318926 (reverse concatenation).
Cf. A382255 (Heinz numbers instead of concatenation of the run lengths).

Programs

  • Mathematica
    Array[FromDigits@ Flatten[IntegerDigits@ Length[#] & /@ Split@ IntegerDigits[#, 2]] &, 40] (* Michael De Vlieger, Feb 17 2022 *)
  • PARI
    a(n) = { my(d=[], r); while(n, n>>=r=valuation(n+n%2, 2); d=concat(digits(r), d)); fromdigits(d) } \\ Rémy Sigrist, Feb 17 2022, edited by M. F. Hasler, Mar 11 2025
    
  • Python
    from itertools import groupby
    def A318927(n): return int(''.join(str(len(list(g))) for k, g in groupby(bin(n)[2:]))) # Chai Wah Wu, Mar 11 2022

A043284 Maximal run length in base-10 representation of n.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

The first term larger than 2 is a(111) = 3. - M. F. Hasler, Jul 21 2013

Crossrefs

Cf. A043276-A043290 for base-2 to base-16 analogs.
Cf. A030556-A030561, A030575-A030580 (related to base-6 run lengths).
Cf. A227186, A227188, A101211, A005811 (related to base-2 run lengths).

Programs

  • Mathematica
    A043284[n_]:=Max[Map[Length,Split[IntegerDigits[n]]]];Array[A043284,100] (* Paolo Xausa, Sep 27 2023 *)
  • PARI
    A043284(n)={my(m,c=1);while(n>0,n%10==(n\=10)%10 && c++ && next;m=max(m,c);c=1);m} \\ M. F. Hasler, Jul 23 2013

Formula

For n < 111, a(n) = 1 except for a(n) = 2 when n==0 (mod 11) or n = 100. - M. F. Hasler, Jul 21 2013

Extensions

Data completed up to a(100), first difference with A083230, by M. F. Hasler, Oct 18 2019

A175930 Concatenation of run lengths in binary expansion of n, written in base 2, then converted to base 10.

Original entry on oeis.org

1, 3, 2, 6, 7, 5, 3, 7, 13, 15, 14, 10, 11, 7, 4, 12, 15, 27, 26, 30, 31, 29, 15, 11, 21, 23, 22, 14, 15, 9, 5, 13, 25, 31, 30, 54, 55, 53, 27, 31, 61, 63, 62, 58, 59, 31, 28, 20, 23, 43, 42, 46, 47, 45, 23, 15, 29, 31, 30, 18, 19, 11, 6, 14, 27, 51, 50, 62, 63, 61, 31, 55, 109, 111
Offset: 1

Views

Author

Dylan Hamilton, Oct 23 2010

Keywords

Examples

			6 = 110, two runs, lengths 2 and 1, so we write down 101 and convert it to base 10, getting 5. So a(6) = 5.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := FromDigits[Flatten[IntegerDigits[Length /@ Split[IntegerDigits[n, \ 2]], 2]], 2]
    Array[f, NUMBER OF TERMS]
  • PARI
    a(n) = my (b=[]); while (n, my (x=valuation(n+(n%2), 2)); b = concat(binary(x), b); n \= 2^x); fromdigits(b, 2) \\ Rémy Sigrist, Jul 02 2019
    
  • Python
    from itertools import groupby
    def a(n):
        c = "".join(bin(len(list(g)))[2:] for k, g in groupby(bin(n)[2:]))
        return int(c, 2)
    print([a(n) for n in range(1, 75)]) # Michael S. Branicky, Oct 02 2021

Formula

From Rémy Sigrist, Jul 02 2019: (Start)
a(2^k-1) = k for any k > 0.
a(2^k) = A004755(k) for any k > 0. (End)

Extensions

Edited by N. J. A. Sloane, Oct 23 2010

A280998 Numbers with a prime number of 1's in their binary reflected Gray code representation.

Original entry on oeis.org

2, 4, 5, 6, 8, 9, 11, 12, 13, 14, 16, 17, 19, 21, 23, 24, 25, 27, 28, 29, 30, 32, 33, 35, 37, 39, 41, 43, 45, 47, 48, 49, 51, 53, 55, 56, 57, 59, 60, 61, 62, 64, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 96, 97, 99, 101, 103
Offset: 1

Views

Author

Indranil Ghosh, Jan 12 2017

Keywords

Comments

From Emeric Deutsch, Jan 28 2018: (Start)
Also the indices of the compositions that have a prime number of parts. For the definition of the index of a composition see A298644.
For example, 27 is in the sequence since its binary form is 11011 and the composition [2,1,2] has 3 parts.
On the other hand, 58 is not in the sequence since its binary form is 111010 and the composition [3,1,1,1] has 4 parts.
The command c(n) from the Maple program yields the composition having index n. (End)

Examples

			27 is in the sequence because the binary reflected Gray code representation of 27 is 10110 which has 3 1's, and 3 is prime.
		

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 175 do if isprime(nops(c(n))) = true then A := `union`(A, {n}) else end if end do: A;
    # most of the program is due to W. Edwin Clark. # Emeric Deutsch, Jan 28 2018
  • Mathematica
    Select[Range[100], PrimeQ[DigitCount[BitXor[#, Floor[#/2]], 2, 1]] &] (* Amiram Eldar, May 01 2021 *)
  • PARI
    is(n)=isprime(hammingweight(bitxor(n, n>>1))) \\ Charles R Greathouse IV, Jan 12 2017

A361644 Irregular triangle T(n, k), n >= 0, k = 1..max(1, 2^(A005811(n)-1)), read by rows; the n-th row lists the integers with the same binary length as n and whose partial sums of run lengths are included in those of n.

Original entry on oeis.org

0, 1, 2, 3, 3, 4, 7, 4, 5, 6, 7, 6, 7, 7, 8, 15, 8, 9, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15, 8, 11, 12, 15, 12, 15, 12, 13, 14, 15, 14, 15, 15, 16, 31, 16, 17, 30, 31, 16, 17, 18, 19, 28, 29, 30, 31, 16, 19, 28, 31, 16, 19, 20, 23, 24, 27, 28, 31
Offset: 0

Views

Author

Rémy Sigrist, Mar 19 2023

Keywords

Comments

In other words, the n-th row contains the numbers k with the same binary length as n and for any i >= 0, if the i-th bit and the (i+1)-th bit in k are different then they are also different in n (i = 0 corresponding to the least significant bit).
The value m appears 2^A092339(m) times in the triangle (see A361674).

Examples

			Triangle begins (in decimal and in binary):
  n   n-th row      bin(n)  n-th row in binary
  --  ------------  ------  ------------------
   0  0                  0  0
   1  1                  1  1
   2  2, 3              10  10, 11
   3  3                 11  11
   4  4, 7             100  100, 111
   5  4, 5, 6, 7       101  100, 101, 110, 111
   6  6, 7             110  110, 111
   7  7                111  111
   8  8, 15           1000  1000, 1111
   9  8, 9, 14, 15    1001  1000, 1001, 1110, 1111
.
For n = 9:
- the binary expansion of 9 is "1001",
- the corresponding run lengths are 1, 2, 1,
- so the 9th row contains the values with the following run lengths:
      1, 2, 1  ->   9 ("1001" in binary)
      1,  2+1  ->   8 ("1000" in binary)
      1+2,  1  ->  14 ("1110" in binary)
       1+2+1   ->  15 ("1111" in binary)
		

Crossrefs

Programs

  • PARI
    row(n) = { my (r = []); while (n, my (v = valuation(n+n%2, 2)); n \= 2^v; r = concat(v, r)); my (s = [if (#r, 2^r[1]-1, 0)]); for (k = 2, #r, s = concat(s * 2^r[k], [(h+1)*2^r[k]-1|h<-s]);); vecsort(s); }

Formula

T(n, 1) = A342126(n).
T(n, max(1, 2^(A005811(n)-1))) = A003817(n).

A371256 The run lengths transform of the ternary expansion of n corresponds to the run lengths transform of the binary expansion of a(n).

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Mar 16 2024

Keywords

Comments

For any v >= 0, the value v appears 2^A005811(v) times in the sequence.

Examples

			The first terms, alongside the ternary expansion of n and the binary expansion of a(n), are:
  n   a(n)  ter(n)  bin(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     1       2          1
   3     2      10         10
   4     3      11         11
   5     2      12         10
   6     2      20         10
   7     2      21         10
   8     3      22         11
   9     4     100        100
  10     5     101        101
  11     5     102        101
  12     6     110        110
  13     7     111        111
  14     6     112        110
  15     5     120        101
		

Crossrefs

See A371263 for a similar sequence.

Programs

  • PARI
    a(n) = { my (r = [], d, l, v = 0); while (n, d = n%3; l = 0; while ((n%3)==d, n\=3; l++;); r = concat(l, r);); for (k = 1, #r, v = (v+k%2)*2^r[k]-k%2); v }

Formula

a(A005823(n)) = n - 1.
a(A005836(n)) = n - 1.
a(A004488(n)) = a(n).
abs(a(n+1) - a(n)) <= 1.

A318926 Take the binary expansion of n, starting with the least significant bit, and concatenate the lengths of the runs.

Original entry on oeis.org

1, 11, 2, 21, 111, 12, 3, 31, 121, 1111, 211, 22, 112, 13, 4, 41, 131, 1121, 221, 2111, 11111, 1211, 311, 32, 122, 1112, 212, 23, 113, 14, 5, 51, 141, 1131, 231, 2121, 11121, 1221, 321, 3111, 12111, 111111, 21111, 2211, 11211, 1311, 411, 42, 132, 1122, 222, 2112, 11112, 1212, 312, 33, 123
Offset: 1

Views

Author

N. J. A. Sloane, Sep 09 2018

Keywords

Comments

Obviously this compressed notation is useful only for n < 2047. A227736 is a version which works for all n. [Corrected by M. F. Hasler, Mar 12 2025]

Examples

			n, binary, run lengths, -> a(n)
1, [1], [1] -> 1
2, [0, 1], [1, 1] -> 11
3, [1, 1], [2] ->  2
4, [0, 0, 1], [2, 1] -> 21
5, [1, 0, 1], [1, 1, 1] -> 111
6, [0, 1, 1], [1, 2] -> 12
7, [1, 1, 1], [3] -> 3
8, [0, 0, 0, 1], [3, 1] ->  31,
...
From _M. F. Hasler_, Mar 12 2025: (Start)
For n = 1023 = 2^10-1, n = '1'*10 in binary, so there is only one run of length 10, whence a(n) = 10. This value cannot occur at any other index n.
For n = 1024 = 2^10, n = '1'+'0'*10 in binary, so the run lengths, from right to left, are [10, 1], whence a(n) = 101. The only other index n for which this value occurs is n = 2^101-1.
For n = 1025 = 2^10+1, n = '1'+'0'*9+'1' in binary, so a(n) = 191. This values occurs for the second time as a(n = 2^19), for the third time for a(n = 2^92-2), and for the 4th and last time as a(n = 2^191-1).
Similarly, a(1026) = 1181 appears for the second time at n = 2^19 + 1 = 524289;
  a(1027) = 281 occurs a 2nd, 3rd and 4th time at n = 2^28, (2^81-1)*2 and 2^281-1.
The first duplicate value occurs as a(2047 = 2^11-1) = 11 = a(2). (End)
		

Crossrefs

Cf. A227736 (run lengths in rows instead of concatenation), A101211 (rows in reverse order), A318927 (concatenation in reverse order).

Programs

  • Mathematica
    A318926[n_] := FromDigits[Flatten[IntegerDigits[Map[Length, Split[Reverse[IntegerDigits[n, 2]]]]]]];
    Array[A318926, 100] (* Paolo Xausa, Mar 16 2025 *)
  • PARI
    A318926(n)=eval(strjoin(Vecrev(A101211_row(n)))); \\ M. F. Hasler, Mar 11 2025
  • Python
    from itertools import groupby
    def A318926(n): return int(''.join(str(len(list(g))) for k, g in groupby(bin(n)[:1:-1]))) # Chai Wah Wu, Mar 11 2022
    

Extensions

More terms from M. F. Hasler, Mar 12 2025

A335835 Sort the run lengths in binary expansion of n in descending order (with multiplicities).

Original entry on oeis.org

0, 1, 2, 3, 6, 5, 6, 7, 14, 13, 10, 13, 12, 13, 14, 15, 30, 29, 26, 25, 26, 21, 26, 29, 28, 25, 26, 25, 28, 29, 30, 31, 62, 61, 58, 57, 50, 53, 50, 57, 58, 53, 42, 53, 50, 53, 58, 61, 60, 57, 50, 51, 50, 53, 50, 57, 56, 57, 58, 57, 60, 61, 62, 63, 126, 125
Offset: 0

Views

Author

Rémy Sigrist, Jun 26 2020

Keywords

Comments

This sequence preserves the number of runs (A005811) and the length (A070939) of the binary representation of a number.

Examples

			For n = 72:
- the binary representation of 72 is "1001000",
- the corresponding run lengths are: 1, 2, 1, 3,
- in descending order: 3, 2, 1, 1,
- so the binary representation of a(72) is "1110010",
- and a(72) = 114.
		

Crossrefs

Cf. A005811, A037016 (fixed points), A070939, A101211, A335834.

Programs

  • PARI
    torl(n) = { my (rr=[]); while (n, my (r=valuation(n+(n%2), 2)); rr = concat(r, rr); n\=2^r); rr }
    fromrl(rr) = { my (v=0); for (k=1, #rr, v = (v+(k%2))*2^rr[k]-(k%2)); v }
    a(n) = { fromrl(vecsort(torl(n),,4)) }

Formula

a(a(n)) = a(n).
Previous Showing 21-30 of 64 results. Next