OFFSET
0,3
COMMENTS
First differences are usually +1, occasionally -4 (because in base i-1 [3]+[7]=(+i)+(-i)=0) hence often a(i+j)=a(i)+a(j). Differences terms given here are period-16, but for full sequence is actually period-256 at least.
a(n) is the sum of the digits of n when written in base -4 using digits 0 to 3 (A007608). This is since in Penney's digit substitution for A066321, the base -4 digits 0 to 3 become bit strings of exactly 0 to 3 many 1-bits each respectively. - Kevin Ryde, Sep 09 2019
REFERENCES
D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, 1969, Vol. 2, p. 172. (Also exercise 16, p. 177, answer, p. 494.)
LINKS
David A. Corneth, Table of n, a(n) for n = 0..9999
Walter Penney, A Binary System for Complex Numbers, NSA Technical Journal, 1965.
Walter Penney, A Binary System for Complex Numbers, Journal of the Association for Computing Machinery (JACM), volume 12, number 2, April 1965, pages 247-248.
FORMULA
EXAMPLE
MATHEMATICA
a[n_] := Plus @@ Mod[NestWhileList[(# - Mod[#, 4])/-4 &, n, # != 0 &], 4]; Array[a, 100, 0] (* Amiram Eldar, Mar 22 2021 *)
PROG
(PARI) a(n) = my(ret=0); while(n, ret+=n%4; n\=-4); ret; \\ Kevin Ryde, Sep 09 2019
CROSSREFS
KEYWORD
nonn,easy,base
AUTHOR
Marc LeBrun, Dec 14 2001
STATUS
approved