OFFSET
0,4
COMMENTS
This sequence is a variant of A117966.
This sequence is a bijection from N = [0..+oo) to Z = (-oo..+oo).
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..6560
Rémy Sigrist, Scatterplot of the first 3^9 terms
FORMULA
Sum_{k = 0..n} a(k) >= 0 with equality iff n belongs to A005823.
EXAMPLE
For n = 0:
- a(3*0) = 3*a(0),
- so a(0) = 0.
For n = 1:
- a(1) = 1 - 3*a(0) = 1.
For n = 2:
- a(2) = 3*a(0) - 1 = -1.
For n = 4:
- a(4) = 1 - 3*a(1) = -2.
PROG
(PARI) a(n) = { if (n==0, return (0), my (d=n%3, m=n\3); if (d==0, 3*a(m), d==1, 1-3*a(m), 3*a(m)-1)) }
CROSSREFS
KEYWORD
sign
AUTHOR
Rémy Sigrist, Oct 18 2020
STATUS
approved