|
|
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.
|
|
2
|
|
|
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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
|
|
LINKS
|
|
|
FORMULA
|
a(n) = 1 iff n is an odd number.
a(n) <= n with equality iff n belongs to A091065.
a(a(n)) = a(n).
|
|
EXAMPLE
|
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.
|
|
PROG
|
(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)
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|