login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A353906 a(n) is the {alternating sum of the digits of n} raised to the power {number of digits of n}. 2
1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 4, 9, 16, 25, 36, 49, 64, 4, 1, 0, 1, 4, 9, 16, 25, 36, 49, 9, 4, 1, 0, 1, 4, 9, 16, 25, 36, 16, 9, 4, 1, 0, 1, 4, 9, 16, 25, 25, 16, 9, 4, 1, 0, 1, 4, 9, 16, 36, 25, 16, 9, 4, 1, 0, 1, 4, 9, 49, 36, 25, 16, 9, 4, 1, 0, 1, 4, 64, 49, 36, 25, 16, 9 (list; graph; refs; listen; history; text; internal format)
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
LINKS
FORMULA
a(n) = A055017(n)^A055642(n).
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
Cf. A055017 (alternating digit sum), A055642 (number of digits).
Cf. A353907 (fixed points).
Cf. A113009 (normal sum instead of alternating).
Sequence in context: A225693 A040997 A256851 * A247149 A330350 A222210
KEYWORD
sign,easy,base
AUTHOR
Malo David, May 10 2022
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 18 22:18 EDT 2024. Contains 371782 sequences. (Running on oeis4.)