cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A180017 Difference of sums of digits of n in ternary and in binary.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Aug 06 2010

Keywords

Comments

This sequence is positive on average, since 1/log(3) > 1/log(4). Do all integers appear infinitely often? - Charles R Greathouse IV, Feb 07 2013

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.
		

Crossrefs

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

Formula

a(n) = A053735(n) - A000120(n);
a(A037301(n)) = 0;
a(A000244(n)) = 1 - A000120(A000244(n));
a(A000079(n)) = A053735(A000079(n)) - 1;
a(A024023(n)) = 2*n - A000120(A024023(n)); a(A000225(n)) = A053735(A000225(n)) - n.
a(n) = A011371(n) - 2*A054861(n). - Henry Bottomley, Feb 16 2024