A344658 a(n) = a^a - b^b + c^c - ... -+ d^d where the decimal expansion of n is abc...d.
1, 1, 4, 27, 256, 3125, 46656, 823543, 16777216, 387420489, 0, 0, -3, -26, -255, -3124, -46655, -823542, -16777215, -387420488, 3, 3, 0, -23, -252, -3121, -46652, -823539, -16777212, -387420485, 26, 26, 23, 0, -229, -3098, -46629, -823516, -16777189, -387420462
Offset: 0
Crossrefs
Cf. A045503.
Programs
-
Mathematica
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 *)
-
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
-
Python
def a(n): return sum(d**d*(-1)**i for i, d in enumerate(map(int, str(n)))) print([a(n) for n in range(40)]) # Michael S. Branicky, May 28 2021
-
newLISP
(define (a n) (if (zero? n) 1 (local (sign out power) (setq power '(1 1 4 27 256 3125 46656 823543 16777216 387420489)) (setq out 0) (if (odd? (length n)) (setq sign 1) (setq sign -1)) (while (!= n 0) (setq out (+ out (* sign (power (% n 10))))) (setq sign (* sign -1)) (setq n (/ n 10))) out)))
Comments