A066323 Number of one bits in binary representation of base i-1 expansion of n (where i = sqrt(-1)).
0, 1, 2, 3, 4, 5, 6, 7, 3, 4, 5, 6, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 4, 5, 6, 7, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 4, 5, 6, 7, 3, 4, 5, 6, 7, 8, 9, 10, 6, 7, 8, 9, 5, 6, 7, 8, 4, 5, 6, 7, 8, 9, 10, 11, 7, 8, 9, 10, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10, 11, 12, 8, 9, 10, 11, 7, 8, 9, 10, 6, 7, 8, 9
Offset: 0
Examples
A066321(4) = 464 = 111010000 (binary) so a(4) = 4. Or A007608(4) == 130 in base -4 and sum of digits is a(4) = 1+3+0 = 4.
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.
Programs
-
Mathematica
a[n_] := Plus @@ Mod[NestWhileList[(# - Mod[#, 4])/-4 &, n, # != 0 &], 4]; Array[a, 100, 0] (* Amiram Eldar, Mar 22 2021 *)
-
PARI
a(n) = my(ret=0); while(n, ret+=n%4; n\=-4); ret; \\ Kevin Ryde, Sep 09 2019
Comments