OFFSET
1,2
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..8191
Rémy Sigrist, PARI program
FORMULA
a(n) <= n with equality iff n is a power of 2.
a(2^k - 1) = 1 for any k > 0.
EXAMPLE
The first terms, in decimal and in binary, are:
n a(n) bin(n) bin(a(n))
-- ---- ------ ---------
1 1 1 1
2 2 10 10
3 1 11 1
4 4 100 100
5 2 101 10
6 5 110 101
7 1 111 1
8 8 1000 1000
9 4 1001 100
10 2 1010 10
11 5 1011 101
12 9 1100 1001
13 5 1101 101
14 11 1110 1011
15 1 1111 1
16 16 10000 10000
PROG
(PARI) \\ See Links section.
(Python)
def a(n):
target = bin(n)[2:]
for m in range(1, n):
b = bin(m)[2:]
mstar = b*(2*len(target)//len(b))
if target in mstar:
return m
return n
print([a(n) for n in range(1, 74)]) # Michael S. Branicky, Jun 14 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jun 04 2024
STATUS
approved