|
|
A274604
|
|
Running sum of Noergaard's "infinity sequence" A004718.
|
|
1
|
|
|
0, 1, 0, 2, 3, 3, 1, 4, 3, 5, 5, 6, 8, 7, 4, 8, 9, 9, 7, 10, 10, 11, 10, 12, 10, 13, 14, 14, 17, 15, 11, 16, 15, 17, 17, 18, 20, 19, 16, 20, 20, 21, 20, 22, 23, 23, 21, 24, 26, 25, 22, 26, 25, 27, 27, 28, 25, 29, 31, 30, 34, 31, 26, 32, 33, 33, 31, 34, 34, 35, 34, 36, 34, 37, 38, 38, 41, 39, 35, 40, 40, 41, 40, 42, 43, 43, 41, 44, 43, 45, 45, 46, 48
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,4
|
|
COMMENTS
|
If s(n) is A004718, then a(2n) = n - s(n) and a(2n+1) = n+1.
|
|
LINKS
|
|
|
MAPLE
|
b:= proc(n) option remember; local r; `if`(n=0, 0,
`if`(irem(n, 2, 'r')=0, -b(r), b(r)+1))
end:
a:= proc(n) a(n):= b(n)+`if`(n=0, 0, a(n-1)) end:
|
|
MATHEMATICA
|
b[n_] := b[n] = Module[{q, r}, If[n == 0, 0, {q, r} = QuotientRemainder[n, 2]; If[r == 0, -b[q], b[q] + 1]]];
a[n_] := b[n] + If[n == 0, 0, a[n - 1]];
|
|
PROG
|
(Python)
from itertools import groupby
if n&1: return (n>>1)+1
c = 0
for k, g in groupby(bin(m:=n>>1)[2:]):
c = c+len(list(g)) if k == '1' else (-c if len(list(g))&1 else c)
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|