login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A331835
Replace 2^k in binary expansion of n with k-th prime number for any k > 0 (and keep 2^0).
3
0, 1, 2, 3, 3, 4, 5, 6, 5, 6, 7, 8, 8, 9, 10, 11, 7, 8, 9, 10, 10, 11, 12, 13, 12, 13, 14, 15, 15, 16, 17, 18, 11, 12, 13, 14, 14, 15, 16, 17, 16, 17, 18, 19, 19, 20, 21, 22, 18, 19, 20, 21, 21, 22, 23, 24, 23, 24, 25, 26, 26, 27, 28, 29, 13, 14, 15, 16, 16
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
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