login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A346732
Replace 9^k with (-1)^k in base-9 expansion of n.
4
0, 1, 2, 3, 4, 5, 6, 7, 8, -1, 0, 1, 2, 3, 4, 5, 6, 7, -2, -1, 0, 1, 2, 3, 4, 5, 6, -3, -2, -1, 0, 1, 2, 3, 4, 5, -4, -3, -2, -1, 0, 1, 2, 3, 4, -5, -4, -3, -2, -1, 0, 1, 2, 3, -6, -5, -4, -3, -2, -1, 0, 1, 2, -7, -6, -5, -4, -3, -2, -1, 0, 1, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, -1, 0, 1, 2, 3, 4
OFFSET
0,3
COMMENTS
If n has base-9 expansion abc..xyz with least significant digit z, a(n) = z - y + x - w + ...
FORMULA
G.f. A(x) satisfies: A(x) = x * (1 + 2*x + 3*x^2 + 4*x^3 + 5*x^4 + 6*x^5 + 7*x^6 + 8*x^7) / (1 - x^9) - (1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8) * A(x^9).
a(n) = n + 10 * Sum_{k>=1} (-1)^k * floor(n/9^k).
EXAMPLE
89 = 108_9, 8 - 0 + 1 = 9, so a(89) = 9.
MATHEMATICA
nmax = 104; A[_] = 0; Do[A[x_] = x (1 + 2 x + 3 x^2 + 4 x^3 + 5 x^4 + 6 x^5 + 7 x^6 + 8 x^7)/(1 - x^9) - (1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8) A[x^9] + O[x]^(nmax + 1) // Normal, nmax + 1]; CoefficientList[A[x], x]
Table[n + 10 Sum[(-1)^k Floor[n/9^k], {k, 1, Floor[Log[9, n]]}], {n, 0, 104}]
PROG
(Python)
from sympy.ntheory.digits import digits
def a(n):
return sum(bi*(-1)**k for k, bi in enumerate(digits(n, 9)[1:][::-1]))
print([a(n) for n in range(105)]) # Michael S. Branicky, Jul 31 2021
KEYWORD
sign,base
AUTHOR
Ilya Gutkovskiy, Jul 30 2021
STATUS
approved