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!)
A257588 If n = abcd... in decimal, a(n) = |a^2 - b^2 + c^2 - d^2 + ...|. 8

%I #25 Jul 11 2022 16:04:43

%S 0,1,4,9,16,25,36,49,64,81,1,0,3,8,15,24,35,48,63,80,4,3,0,5,12,21,32,

%T 45,60,77,9,8,5,0,7,16,27,40,55,72,16,15,12,7,0,9,20,33,48,65,25,24,

%U 21,16,9,0,11,24,39,56,36,35,32,27,20,11,0,13,28,45,49

%N If n = abcd... in decimal, a(n) = |a^2 - b^2 + c^2 - d^2 + ...|.

%C a(n) = 0 iff n is in A352535. - _Bernard Schott_, Jul 08 2022

%H Reinhard Zumkeller, <a href="/A257588/b257588.txt">Table of n, a(n) for n = 0..10000</a>

%p a:= n-> (l-> abs(add(l[i]^2*(-1)^i, i=1..nops(l))))(convert(n, base, 10)):

%p seq(a(n), n=0..70); # _Alois P. Heinz_, Mar 24 2022

%t Array[Abs@ Total@ MapIndexed[(2 Boole@ EvenQ[First[#2]] - 1) (#1^2) &, IntegerDigits[#]] &, 70] (* _Michael De Vlieger_, Feb 27 2022 *)

%o (Haskell)

%o a257588 = abs . f 1 where

%o f _ 0 = 0

%o f s x = s * d ^ 2 + f (negate s) x' where (x', d) = divMod x 10

%o -- _Reinhard Zumkeller_, May 10 2015

%o (Python)

%o def A257588(n):

%o return abs(sum((int(d)**2*(-1)**j for j,d in enumerate(str(n)))))

%o # _Chai Wah Wu_, May 10 2015

%o (PARI) a(n) = my(d=digits(n)); abs(sum(k=1, #d, (-1)^k*d[k]^2)); \\ _Michel Marcus_, Feb 27 2022

%Y Cf. A257587, A257796.

%Y Cf. A225693, A003132, A352535.

%K nonn,base

%O 0,3

%A _N. J. A. Sloane_, May 10 2015

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 16 12:05 EDT 2024. Contains 371711 sequences. (Running on oeis4.)