login
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
OFFSET
0,4
COMMENTS
If s(n) is A004718, then a(2n) = n - s(n) and a(2n+1) = n+1.
LINKS
Yu Hin (Gary) Au, Christopher Drexler-Lemire & Jeffrey Shallit, Notes and note pairs in Nørgård's infinity series, Journal of Mathematics and Music, Volume 11, 2017, Issue 1, pages 1-19.
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:
seq(a(n), n=0..100); # Alois P. Heinz, Jun 30 2016
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]];
a /@ Range[0, 100] (* Jean-François Alcover, Nov 24 2020, after Alois P. Heinz *)
PROG
(Python)
from itertools import groupby
def A274604(n):
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)
return m-c # Chai Wah Wu, Mar 03 2023
CROSSREFS
Cf. A004718.
Sequence in context: A114104 A076780 A324733 * A089283 A288531 A323942
KEYWORD
nonn
AUTHOR
Jeffrey Shallit, Jun 30 2016
STATUS
approved