OFFSET
0,4
COMMENTS
The idea is to keep the 1's in the binary expansion of a number whose positions are related in some way to that number.
LINKS
FORMULA
a(n) <= n with equality iff n belongs to A309274.
EXAMPLE
For n = 42:
- 42 = 2^5 + 2^3 + 2^1,
- 42 AND 5 = 0 <> 5,
- 42 AND 3 = 2 <> 3,
- 42 AND 1 = 0 <> 1,
- so a(42) = 0.
PROG
(PARI) a(n) = { my (v=0, m=n, k); while (m, m-=2^k=valuation(m, 2); if (bitand(n, k)==k, v+=2^k)); v }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Mar 16 2022
STATUS
approved