OFFSET
1,2
COMMENTS
The first negative term is a(120) = -1.
Note that it does not matter whether the alternating sum starts from the first or from the last digit of n. - Jianing Song, Jun 12 2022
EXAMPLE
For n=489, a(489) = (9-8+4)^3 = 125.
MATHEMATICA
a[n_] := Total[-(-1)^Range[m = Length[d = IntegerDigits[n]]] * d]^m; Array[a, 100] (* Amiram Eldar, May 11 2022 *)
PROG
(Python)
def a(n):
counter = 0
S = 0
q = n
while q:
q, c = q//10, q % 10
S += (-1)** counter * c
counter += 1
return S ** counter
(Python)
def A353906(n): return sum((-1 if i % 2 else 1)*int(j) for i, j in enumerate(str(n)[::-1]))**len(str(n)) # Chai Wah Wu, May 11 2022
(PARI) a(n) = my(d=digits(n)); sum(k=1, #d, (-1)^(k+1)*d[k])^#d; \\ Michel Marcus, May 10 2022
CROSSREFS
KEYWORD
sign,easy,base
AUTHOR
Malo David, May 10 2022
STATUS
approved