OFFSET
1,2
COMMENTS
LINKS
FORMULA
a(2*n) = a(n) for any n > 1.
a(n) = n iff n is not composite.
a(n) = 2 iff n = 2^k for some k > 0.
a(n) >= A078833(n).
EXAMPLE
The first terms, alongside the binary representations of n and of a(n), are:
n a(n) bin(n) bin(a(n))
-- ---- ------ ---------
1 1 1 1
2 2 10 10
3 3 11 11
4 2 100 10_
5 5 101 101
6 3 110 11_
7 7 111 111
8 2 1000 10__
9 5 1001 10_1
10 5 1010 101_
11 11 1011 1011
12 3 1100 11__
13 13 1101 1101
14 7 1110 111_
15 7 1111 111_
PROG
(PARI) a(n) = my (s=Set(1), b=binary(n)); for (i=2, #b, s=setunion(s, Set(apply(k->2*k+b[i], s)))); vecmax(select(k->k==1 || isprime(k), s))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 18 2018
STATUS
approved