login
A355675
a(0) = 0, and for any n > 0 and d = 1..9, a(10*n) = 10*a(n), a(10*n + d) = d - 10*a(n).
2
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 20, -19, -18, -17, -16, -15, -14, -13, -12, -11, 30, -29, -28, -27, -26, -25, -24, -23, -22, -21, 40, -39, -38, -37, -36, -35, -34, -33, -32, -31, 50, -49, -48, -47, -46, -45, -44, -43, -42
OFFSET
0,3
COMMENTS
This sequence establishes a bijection from the nonnegative integers (N) to the integers (Z).
This sequence is to base 10 what A065620 is to base 2.
To compute a(n): write n a sum of terms of A037124 with distinct 10-adic valuations and take the alternating sum.
This sequence has similarities with A073835; they first differ in absolute value for n = 101: a(101) = 99 whereas A073835(101) = 101.
This sequence has similarities with A334387; they first differ in absolute value for n = 111: a(111) = 91 whereas A334387(111) = 81.
FORMULA
a(n) = 0 iff n = 0 or n belongs to A037124.
EXAMPLE
For n = 17039:
17039 = 10000 + 7000 + 30 + 9,
so a(17039) = -10000 + 7000 - 30 + 9 = -3021.
PROG
(PARI) a(n, base=10) = { my (d=digits(n, base), s=1); forstep (k=#d, 1, -1, if (d[k], d[k]*=s; s=-s)); return (fromdigits(d, base)) }
CROSSREFS
KEYWORD
sign,base,easy
AUTHOR
Rémy Sigrist, Jul 14 2022
STATUS
approved