A180017 Difference of sums of digits of n in ternary and in binary.
0, 0, 1, -1, 1, 1, 0, 0, 3, -1, 0, 0, 0, 0, 1, -1, 3, 3, 0, 0, 2, 0, 1, 1, 2, 2, 3, -3, -1, -1, -2, -2, 3, 1, 2, 2, 0, 0, 1, -1, 2, 2, 1, 1, 3, -1, 0, 0, 2, 2, 3, 1, 3, 3, -2, -2, 1, -1, 0, 0, 0, 0, 1, -3, 3, 3, 2, 2, 4, 2, 3, 3, 2, 2, 3, 1, 3, 3, 2, 2, 6, -2, -1, -1, -1, -1, 0, -2, 1, 1, -2, -2, 0
Offset: 0
Examples
For n = 7 = 21_3 = 111_2, a(n) = (2+1) - (1+1+1) = 0. For n = 8 = 22_3 = 1000_2, a(n) = (2+2) - (1+0+0+0) = 3. For n = 9 = 100_3 = 1001_2, a(n) = (1+0+0) - (1+0+0+1) = -1.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
Programs
-
Mathematica
Table[Total[IntegerDigits[n,3]]-Total[IntegerDigits[n,2]],{n,0,100}] (* Harvey P. Dale, Dec 08 2015 *)
-
PARI
a(n) = sumdigits(n,3) - sumdigits(n,2); \\ Michel Marcus, Nov 12 2023
Comments