The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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!)
A244144 Alternating sum of digits of n^n. 3

%I #12 Jun 21 2014 16:43:56

%S 1,4,-5,3,-1,5,5,-5,5,1,-11,-10,8,4,21,-38,8,-2,7,1,1,0,10,-5,23,26,3,

%T -7,19,23,-24,23,11,56,10,36,5,37,24,-32,8,15,-1,-33,-10,20,20,-35,31,

%U 23,-18,24,-14,-34,0,-1,40,16,14,-21,6,-27,-17,-5,-32,11,12,-41,59,-23,-38,52,-42,-29,-21,12,0,-1,-39,1,-7,-19,-7,-25,-34

%N Alternating sum of digits of n^n.

%C The alternating sum of the digits of n^n is the sum obtained by alternately adding and subtracting the digits of n^n from left to right. For example, 4^4 = 256, therefore the alternating sum = 2 - 5 + 6 = 3. 7^7 = 823543, alternating sum = 8 - 2 + 3 - 5 + 4 - 3 = 5.

%H Alois P. Heinz, <a href="/A244144/b244144.txt">Table of n, a(n) for n = 1..5000</a>

%e If the function f(x) alternately adds and subtracts the digits of x from left to right, then:

%e a(1) = f(1^1) = f(1) = 1.

%e a(2) = f(2^2) = f(4) = 4.

%e a(3) = f(3^3) = f(27) = 2 - 7 = -5.

%e a(4) = f(4^4) = f(256) = 2 - 5 + 6 = 3.

%e a(9) = f(9^9) = f(387420489) = 3 - 8 + 7 - 4 + 2 - 0 + 4 - 8 + 9 = 5.

%p a:= n-> -(s->add(parse(s[i])*(-1)^i, i=1..length(s)))(""||(n^n)):

%p seq(a(n), n=1..80); # _Alois P. Heinz_, Jun 21 2014

%t f[n_] := Block[ {d = Reverse[ IntegerDigits[ n]], k = l = 1, s = 0}, l = Length[d]; While[ k <= l, s = s - (-1)^k*d[[k]]; k++ ]; Return[s]]; Table[ f[n^n], {n, 1, 100} ] \\ Minor adaptation from program for A065796.

%Y Cf. A065796, A066588.

%K sign,base,less

%O 1,2

%A _Anthony Sand_, Jun 21 2014

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 June 16 13:54 EDT 2024. Contains 373429 sequences. (Running on oeis4.)