A371905 Let k = 0 and let A007814(2*n) = m; If m > k then a(n) = k = k + m, otherwise a(n) = k = k - m.
1, 3, 2, 5, 4, 2, 1, 5, 4, 2, 1, 4, 3, 1, 0, 5, 4, 2, 1, 4, 3, 1, 0, 4, 3, 1, 0, 3, 2, 0, 1, 7, 6, 4, 3, 0, 1, 3, 2, 6, 5, 3, 2, 5, 4, 2, 1, 6, 5, 3, 2, 5, 4, 2, 1, 5, 4, 2, 1, 4, 3, 1, 0, 7, 6, 4, 3, 0, 1, 3, 2, 6, 5, 3, 2, 5, 4, 2, 1, 6, 5, 3, 2, 5, 4, 2, 1
Offset: 1
Examples
Let f(x) = A007814(x). a(1) = 1 because k = 0 and f(2*1) = 1; since 0 < 1, a(1) = k = 0 + 1 = 1. a(2) = 3 because k = 1 and f(2*2) = 2; since 1 < 2, a(2) = k = 1 + 2 = 3. a(3) = 2 because k = 3 and f(2*3) = 1; since 3 > 2, a(3) = k = 3 - 1 = 2, etc.
Links
- Michael De Vlieger, Table of n, a(n) for n = 1..10000
Crossrefs
Cf. A007814.
Programs
-
Mathematica
nn = 120; k = 0; q = 2; Reap[Do[If[k < #, k += #, k -= #] &@ IntegerExponent[q*n, q]; Sow[k], {n, nn}]][[-1, 1]]