OFFSET
0,3
COMMENTS
Every nonnegative integer appears in this sequence as A008578 is a complete sequence.
For any m >= 0, m appears A036497(m) times, the first and last occurrences being at indices A345297(m) and A200947(m), respectively. - Rémy Sigrist, Jun 13 2021
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8192
Eric Weisstein's World of Mathematics, Complete Sequence
FORMULA
a(2*n) = A089625(n) for any n > 0.
a(2*n+1) = A089625(n) + 1 for any n > 0.
G.f.: x/(1 - x^2) + (1/(1 - x)) * Sum_{k>=1} prime(k) * x^(2^k) / (1 + x^(2^k)). - Ilya Gutkovskiy, May 24 2024
EXAMPLE
For n = 43:
- 43 = 2^0 + 2^1 + 2^3 + 2^5,
- so a(43) = 2^0 + prime(1) + prime(3) + prime(5) = 1 + 2 + 5 + 11 = 19.
MATHEMATICA
Array[Total@ Map[If[# == 0, 1, Prime[#]] &, Position[Reverse@ IntegerDigits[#, 2], 1][[All, 1]] - 1] &, 68] (* Michael De Vlieger, Jan 29 2020 *)
PROG
(PARI) a(n) = my (b=Vecrev(binary(n\2))); n%2 + sum(k=1, #b, if (b[k], prime(k), 0))
(Python)
from sympy import prime
def p(n): return prime(n) if n >= 1 else 1
def a(n): return sum(p(i)*int(b) for i, b in enumerate(bin(n)[:1:-1]))
print([a(n) for n in range(69)]) # Michael S. Branicky, Jun 13 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jan 28 2020
STATUS
approved