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.

Showing 1-8 of 8 results.

A328596 Numbers whose reversed binary expansion is a Lyndon word (aperiodic necklace).

Original entry on oeis.org

1, 2, 4, 6, 8, 12, 14, 16, 20, 24, 26, 28, 30, 32, 40, 44, 48, 52, 56, 58, 60, 62, 64, 72, 80, 84, 88, 92, 96, 100, 104, 106, 108, 112, 116, 118, 120, 122, 124, 126, 128, 144, 152, 160, 164, 168, 172, 176, 180, 184, 188, 192, 200, 208, 212, 216, 218, 220, 224
Offset: 1

Views

Author

Gus Wiseman, Oct 22 2019

Keywords

Comments

First differs from A091065 in lacking 50.
A Lyndon word is a finite sequence that is lexicographically strictly less than all of its cyclic rotations.

Examples

			The sequence of terms together with their binary expansions and binary indices begins:
   1:      1 ~ {1}
   2:     10 ~ {2}
   4:    100 ~ {3}
   6:    110 ~ {2,3}
   8:   1000 ~ {4}
  12:   1100 ~ {3,4}
  14:   1110 ~ {2,3,4}
  16:  10000 ~ {5}
  20:  10100 ~ {3,5}
  24:  11000 ~ {4,5}
  26:  11010 ~ {2,4,5}
  28:  11100 ~ {3,4,5}
  30:  11110 ~ {2,3,4,5}
  32: 100000 ~ {6}
  40: 101000 ~ {4,6}
  44: 101100 ~ {3,4,6}
  48: 110000 ~ {5,6}
  52: 110100 ~ {3,5,6}
  56: 111000 ~ {4,5,6}
  58: 111010 ~ {2,4,5,6}
		

Crossrefs

A similar concept is A275692.
Aperiodic words are A328594.
Necklaces are A328595.
Binary Lyndon words are A001037.
Lyndon compositions are A059966.

Programs

  • Mathematica
    aperQ[q_]:=Array[RotateRight[q,#]&,Length[q],1,UnsameQ];
    neckQ[q_]:=Array[OrderedQ[{q,RotateRight[q,#]}]&,Length[q]-1,1,And];
    Select[Range[100],aperQ[Reverse[IntegerDigits[#,2]]]&&neckQ[Reverse[IntegerDigits[#,2]]]&]

Formula

Intersection of A328594 and A328595.

A091066 Numbers having in binary representation at least one proper prefix that is also a suffix.

Original entry on oeis.org

3, 5, 7, 9, 10, 11, 13, 15, 17, 18, 19, 21, 22, 23, 25, 27, 29, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 45, 46, 47, 49, 51, 53, 54, 55, 57, 59, 61, 63, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89, 90, 91, 93, 94, 95, 97, 99, 101
Offset: 1

Views

Author

Reinhard Zumkeller, Dec 17 2003

Keywords

Comments

A091064(a(n)) > 0, complement of A091065.
Includes all odd numbers > 1. - Robert Israel, Feb 05 2016

Crossrefs

Programs

  • Maple
    f:= proc(n) local L,m;
       if n::odd then return true fi;
       L:= convert(n,base,2);
       for m from 2 to nops(L)-1 do
         if L[1..m] = L[-m..-1] then return true fi;
       od:
       false
    end proc:
    select(f, [$2..101]); # Robert Israel, Feb 05 2016

A242869 Largest integer m < n having a binary expansion that is a prefix and a suffix of the binary expansion of n; a(0)=0.

Original entry on oeis.org

0, 0, 0, 1, 0, 1, 0, 3, 0, 1, 2, 1, 0, 1, 0, 7, 0, 1, 2, 1, 0, 5, 2, 1, 0, 1, 0, 3, 0, 1, 0, 15, 0, 1, 2, 1, 4, 1, 2, 1, 0, 1, 10, 1, 0, 5, 2, 1, 0, 1, 0, 3, 0, 1, 6, 3, 0, 1, 0, 3, 0, 1, 0, 31, 0, 1, 2, 1, 4, 1, 2, 1, 0, 9, 2, 1, 4, 1, 2, 1, 0, 1, 2, 1, 0, 21
Offset: 0

Views

Author

Alois P. Heinz, May 24 2014

Keywords

Comments

The prefix and the suffix are allowed to overlap.
a(n) <= A147755(n).
a(2^n) = 0.
a(2^n-1) = 2^(n-1)-1 for n>0.
a(n) = 0 iff n in { A091065 }.
a(n) > 1 iff n in { A091066 }.
A029837(a(n)+1) = A091064(n).

Examples

			a(91) = 11 because 91 = (1011)011_2 = 101(1011)_2 and 11 = 1011_2.
a(84) = 0 because 84 = 1010100_2, only the empty bitstring is a proper prefix and suffix.
		

Crossrefs

Cf. A147755.

Programs

  • Maple
    a:= proc(n) local m; m:=n;
          while m>1 do m:= iquo(m, 2);
            if m=irem(n, 2^(1+ilog2(m))) then return m fi
          od; 0
        end:
    seq(a(n), n=0..100);

A091064 In binary representation: length of longest proper prefix of n, that is also a suffix.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Dec 17 2003

Keywords

Comments

a(n) <= A070939(n)-1 by definition;
a(2^k-1)=k-1; for k>0: a(2^k+1)=1; for k>2: a(2^k+2)=2;
a(A091065(n)) = 0, a(A091066(n)) > 0.

Crossrefs

A342241 a(n) is the least k > 0 such that the first k bits and the last k bits in the binary expansion of n are the same.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Mar 07 2021

Keywords

Comments

This sequence gives the length of the least nonempty prefix that is also a suffix of the binary expansion of a number.

Examples

			For n = 42:
- the binary representation of 42 is "101010",
- the first bit ("1") and the last bit ("0") do not match,
- the first 2 bits ("10") and the last 2 bits ("10") match,
- so a(42) = 2.
		

Crossrefs

Programs

  • PARI
    a(n) = { my (b=if (n, binary(n), [0])); for (w=1, oo, if (b[1..w]==b[#b+1-w..#b], return (w))) }
    
  • Python
    def a(n):
      b = bin(n)[2:]
      for i in range(1, len(b)+1):
        if b[:i] == b[-i:]: return i
    print([a(n) for n in range(87)]) # Michael S. Branicky, Mar 07 2021

Formula

a(n) = 1 iff n = 0 or n is odd.
a(n) <= A070939(n) with equality iff n belongs to A091065.
a(n) = A070939(A342242(n)).

A342242 For any n > 0, a(n) is the least positive number whose binary expansion is both a prefix and a suffix of the binary expansion of n; a(0) = 0.

Original entry on oeis.org

0, 1, 2, 1, 4, 1, 6, 1, 8, 1, 2, 1, 12, 1, 14, 1, 16, 1, 2, 1, 20, 1, 2, 1, 24, 1, 26, 1, 28, 1, 30, 1, 32, 1, 2, 1, 4, 1, 2, 1, 40, 1, 2, 1, 44, 1, 2, 1, 48, 1, 50, 1, 52, 1, 6, 1, 56, 1, 58, 1, 60, 1, 62, 1, 64, 1, 2, 1, 4, 1, 2, 1, 72, 1, 2, 1, 4, 1, 2, 1
Offset: 0

Views

Author

Rémy Sigrist, Mar 07 2021

Keywords

Comments

All terms belong to A091065.

Examples

			For n = 814:
- the binary expansion of 814 is "1100101110",
- "1" does not match "0",
- "11" does not match "10",
- "110" matches "110",
- so the binary representation of a(814) is "110",
- and a(814) = 6.
		

Crossrefs

Programs

  • PARI
    a(n) = { my (b=if (n, binary(n), [0])); for (w=1, oo, if (b[1..w]==b[#b+1-w..#b], return (fromdigits(b[1..w],2)))) }
    
  • Python
    def a(n):
      b = bin(n)[2:]
      for i in range(1, len(b)+1):
        if b[:i] == b[-i:]: return int(b[:i], 2)
    print([a(n) for n in range(80)]) # Michael S. Branicky, Mar 07 2021

Formula

a(n) = 1 iff n is an odd number.
a(n) <= n with equality iff n belongs to A091065.
a(n) = n mod 2^A342241(n).
a(a(n)) = a(n).

A331392 Sum, over all binary strings w of length n, of the length of the shortest border of w.

Original entry on oeis.org

0, 2, 4, 12, 24, 60, 120, 264, 528, 1116, 2232, 4584, 9168, 18616, 37232, 75056, 150112, 301556, 603112, 1209064, 2418128, 4842504, 9685008, 19383408, 38766816, 77562648, 155125296, 310312528, 620625056, 1241382832, 2482765664, 4965813280, 9931626560
Offset: 1

Views

Author

Jeffrey Shallit, Jan 15 2020

Keywords

Comments

A nonempty word w is a border of a string x if w is both a prefix and suffix of x, and w does not equal x.

Examples

			For n = 3, the words are 000,001,010,011 and their binary complements.  The shortest border of 000 and 010 is 0, and the other words have no border.  So a(3) = 4.
		

Crossrefs

Formula

From Rémy Sigrist, Jan 16 2020: (Start)
Apparently, for any k > 0:
- a(2*k+1) = 2*a(k),
- a(2*k) = 2*a(2*k-1) + 2*k*A045690(k).
(End)

Extensions

More terms from Rémy Sigrist, Jan 15 2020

A361942 For any number n >= 0 with binary expansion (b_1, ..., b_w), a(n) is the least p > 0 such that b_i = b_{p+i} for i = 1..w-p.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Mar 31 2023

Keywords

Comments

Leading zeros in binary expansions of positive integers are ignored.
This sequence is a variant of A302291 related to fractional powers of words.
For any k > 0, the value k appears A045690(k) times in a(2^(k-1)), ..., a(2^k-1).

Examples

			The first terms, alongside the binary expansion of n split into chunks of length a(n), are:
  n   a(n)  bin(n)
  --  ----  ------
   0     1  0
   1     1  1
   2     2  10
   3     1  1|1
   4     3  100
   5     2  10|1
   6     3  110
   7     1  1|1|1
   8     4  1000
   9     3  100|1
  10     2  10|10
  11     3  101|1
  12     4  1100
  13     3  110|1
  14     4  1110
  15     1  1|1|1|1
		

References

  • Jean-Paul Allouche and Jeffrey Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 23.

Crossrefs

Programs

  • PARI
    a(n) = { my (b = if (n, binary(n), [0])); for (p = 1, oo, if (b[1..#b-p] == b[1+p..#b], return (p););); }

Formula

a(n) <= A302291(n).
a(n) <= A070939(n) with equality iff n belongs to A091065.
a(2^k-1) = 1 for any k >= 0.
a(2^k) = k+1 for any k >= 0.
Showing 1-8 of 8 results.