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.

A344658 a(n) = a^a - b^b + c^c - ... -+ d^d where the decimal expansion of n is abc...d.

This page as a plain text file.
%I A344658 #33 Jun 20 2021 16:36:16
%S A344658 1,1,4,27,256,3125,46656,823543,16777216,387420489,0,0,-3,-26,-255,
%T A344658 -3124,-46655,-823542,-16777215,-387420488,3,3,0,-23,-252,-3121,
%U A344658 -46652,-823539,-16777212,-387420485,26,26,23,0,-229,-3098,-46629,-823516,-16777189,-387420462
%N A344658 a(n) = a^a - b^b + c^c - ... -+ d^d where the decimal expansion of n is abc...d.
%C A344658 A045503 sums the corresponding powers of digits. This sequence alternates addition and subtraction of the powers of digits.
%t A344658 pow[n_] := If[n == 0, 1, n^n]; a[n_] := Total[pow /@ (d = IntegerDigits[n])*(-1)^Range[0, Length[d] - 1]]; Array[a, 40, 0] (* _Amiram Eldar_, May 28 2021 *)
%o A344658 (newLISP)
%o A344658 (define (a n)
%o A344658   (if (zero? n) 1
%o A344658     (local (sign out power)
%o A344658       (setq power '(1 1 4 27 256 3125 46656 823543 16777216 387420489))
%o A344658       (setq out 0)
%o A344658       (if (odd? (length n))
%o A344658           (setq sign 1)
%o A344658           (setq sign -1))
%o A344658       (while (!= n 0)
%o A344658         (setq out (+ out (* sign (power (% n 10)))))
%o A344658         (setq sign (* sign -1))
%o A344658         (setq n (/ n 10)))
%o A344658       out)))
%o A344658 (PARI) a(n) = if(n, my(d=digits(n)); sum(k=1, #d, (-1)^(k+1)*d[k]^d[k]), 1) \\ _Felix Fröhlich_ and _Michel Marcus_, May 26 + 31 2021
%o A344658 (Python)
%o A344658 def a(n): return sum(d**d*(-1)**i for i, d in enumerate(map(int, str(n))))
%o A344658 print([a(n) for n in range(40)]) # _Michael S. Branicky_, May 28 2021
%Y A344658 Cf. A045503.
%K A344658 sign,base
%O A344658 0,3
%A A344658 _Massimo Corinaldesi_, May 26 2021