|
|
A089625
|
|
Replace 2^k in binary expansion of n with (k+1)-st prime.
|
|
13
|
|
|
2, 3, 5, 5, 7, 8, 10, 7, 9, 10, 12, 12, 14, 15, 17, 11, 13, 14, 16, 16, 18, 19, 21, 18, 20, 21, 23, 23, 25, 26, 28, 13, 15, 16, 18, 18, 20, 21, 23, 20, 22, 23, 25, 25, 27, 28, 30, 24, 26, 27, 29, 29, 31, 32, 34, 31, 33, 34, 36, 36, 38, 39, 41, 17, 19, 20, 22, 22, 24, 25, 27
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
A000586(n) > 0 iff n = a(m) for some m;
a(n) = n for n = 9, 10, or 12.
|
|
LINKS
|
Eric Weisstein's World of Mathematics, Binary
|
|
FORMULA
|
a(n) = Sum_{i=0..L(n)-1} b(i)*prime(i+1) where L=A070939 and b is defined by n = Sum_{i=0..L(n)-1} b(i)*2^i.
G.f.: 1/(1-x) * Sum_{k>=0} prime(k+1)*x^2^k/(1+x^2^k).
For n >= 8, a(n) <= m*(m+1)*(log(m)+log(log(m)))/2 where m = ceiling(log_2(n)). - Robert Israel, Jun 08 2015
|
|
EXAMPLE
|
n=25 -> '11001': a(25) = 1*11 + 1*7 + 0*5 + 0*3 + 1*2 = 20.
This sequence regarded as a triangle with rows of lengths 1, 2, 4, 8, 16, ...:
2
3, 5
5, 7, 8, 10
7, 9, 10, 12, 12, 14, 15, 17
11, 13, 14, 16, 16, 18, 19, 21, 18, 20, 21, 23, 23, 25, 26, 28
|
|
MAPLE
|
f:= proc(n) local L, j;
L:= convert(n, base, 2);
add(L[i]*ithprime(i), i=1..nops(L))
end proc:
|
|
MATHEMATICA
|
a[n_] := With[{bb = IntegerDigits[n, 2]}, bb.Prime[Range[Length[bb], 1, -1]]];
|
|
PROG
|
(PARI) a(n)=my(v=Vecrev(binary(n)), s, i); forprime(p=2, prime(#v), s+=v[i++]*p); s \\ Charles R Greathouse IV, Sep 23 2012
(Haskell)
a089625 n = f n 0 a000040_list where
f 0 y _ = y
f x y (p:ps) = f x' (y + p * r) ps where (x', r) = divMod x 2
(Python)
from sympy import nextprime
c, p = 0, 2
while n:
if n&1:
c += p
n >>=1
p = nextprime(p)
|
|
CROSSREFS
|
Other sequences that are built by replacing 2^k in the binary representation with other numbers: A029931 (natural numbers), A059590 (factorials), A022290 (Fibonacci).
|
|
KEYWORD
|
nonn,tabf
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|