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.

A353906 a(n) is the {alternating sum of the digits of n} raised to the power {number of digits of n}.

This page as a plain text file.
%I A353906 #40 Jun 12 2022 04:29:17
%S A353906 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,
%T A353906 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,
%U A353906 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
%N A353906 a(n) is the {alternating sum of the digits of n} raised to the power {number of digits of n}.
%C A353906 The first negative term is a(120) = -1.
%C A353906 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
%F A353906 a(n) = A055017(n)^A055642(n).
%e A353906 For n=489, a(489) = (9-8+4)^3 = 125.
%t A353906 a[n_] := Total[-(-1)^Range[m = Length[d = IntegerDigits[n]]] * d]^m; Array[a, 100] (* _Amiram Eldar_, May 11 2022 *)
%o A353906 (Python)
%o A353906 def a(n):
%o A353906    counter = 0
%o A353906    S = 0
%o A353906    q = n
%o A353906    while q:
%o A353906       q, c = q//10, q % 10
%o A353906       S += (-1)** counter * c
%o A353906       counter += 1
%o A353906    return S ** counter
%o A353906 (Python)
%o A353906 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
%o A353906 (PARI) a(n) = my(d=digits(n)); sum(k=1, #d, (-1)^(k+1)*d[k])^#d; \\ _Michel Marcus_, May 10 2022
%Y A353906 Cf. A055017 (alternating digit sum), A055642 (number of digits).
%Y A353906 Cf. A353907 (fixed points).
%Y A353906 Cf. A113009 (normal sum instead of alternating).
%K A353906 sign,easy,base
%O A353906 1,2
%A A353906 _Malo David_, May 10 2022