login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A049802 a(n) = n mod 2 + n mod 4 + ... + n mod 2^k, where 2^k<=n<2^(k+1). 1
0, 0, 1, 0, 2, 2, 4, 0, 3, 4, 7, 4, 7, 8, 11, 0, 4, 6, 10, 8, 12, 14, 18, 8, 12, 14, 18, 16, 20, 22, 26, 0, 5, 8, 13, 12, 17, 20, 25, 16, 21, 24, 29, 28, 33, 36, 41, 16, 21, 24, 29, 28, 33, 36, 41, 32, 37, 40, 45, 44, 49, 52, 57, 0, 6, 10, 16, 16 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,5

COMMENTS

There is the following connection between this sequence and A080277: A080277(n) = n + n*floor(log_2(n)) - a(n). Since A080277(n) is the solution to a prototypical recurrence in the analysis of the algorithm Merge Sort, that is, T(0):=0, T(n):=2*T(floor(n/2))+n, the sequence a(n) seems to be the major obstacle when trying to find a simple, sum-free solution to this recurrence. It seems hard to get rid of the sum. - Peter C. Heinig (algorithms(AT)gmx.de), Oct 21 2006

When n = 2^k with k>0 then a(n+1) = k. For this reason, when n-1 is a Mersenne prime then n-1 = M(p) = 2^p - 1 = (2^a(n+1)) - 1 and p = a(n+1) is prime. - David Morales Marciel, Oct 23 2015

LINKS

Paolo P. Lava, Table of n, a(n) for n = 1..1000

FORMULA

From Robert Israel, Oct 23 2015: (Start)

a(2n) = 2a(n).

a(2n+1) = 2a(n) + A070939(n) for n >= 1.

G.f. A(x) satisfies A(x) = 2*(1+x)*A(x^2) + (x/(1-x^2))*Sum_{i>=1} x^(2^i). (End)

MAPLE

with(numtheory); P:=proc(q) local a, b, c, n; a:=0;

for n from 1 to q do a:=convert(n, binary, decimal); b:=1; c:=0;

while (a mod 10^b)<a do c:=c+convert((a mod 10^b), decimal, binary);

b:=b+1; od; print(c); od; end: P(1000); # Paolo P. Lava, Aug 22 2013

f:= proc(n) option remember; local m;

    if n::even then 2*procname(n/2)

    else m:= (n-1)/2; 2*procname(m) + ilog2(m) + 1

    fi

end proc:

f(1):= 0:

map(f, [$1..1000]); # Robert Israel, Oct 23 2015

MATHEMATICA

Table[n * Floor@Log[2, n] - Sum[Floor[n*2^-k]*2^k, {k, Log[2, n]}], {n, 100}] (* Federico Provvedi, Aug 17 2013 *)

CROSSREFS

Cf. A070939, A080277.

Sequence in context: A246846 A127528 A063070 * A129240 A246816 A127786

Adjacent sequences:  A049799 A049800 A049801 * A049803 A049804 A049805

KEYWORD

nonn

AUTHOR

Clark Kimberling

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy .

Last modified July 23 12:58 EDT 2016. Contains 274958 sequences.