login
Squares in which parity of digits alternates.
24

%I #15 Aug 17 2018 10:48:18

%S 0,1,4,9,16,25,36,49,81,121,169,256,361,529,676,729,961,1296,4761,

%T 5476,6561,7056,9216,12321,12769,14161,16129,18769,32761,34969,41616,

%U 56169,69696,72361,74529,76729,78961,87616,96721,147456,163216,181476,212521

%N Squares in which parity of digits alternates.

%H Giovanni Resta, <a href="/A030152/b030152.txt">Table of n, a(n) for n = 1..10000</a> (first 1000 terms from Reinhard Zumkeller)

%F A010052(a(n)) * A228710(a(n)) = 1. - _Reinhard Zumkeller_, Aug 31 2013

%e 1296 is a term as 1, 2, 9 and 6 have odd and even parity alternately.

%p i := 0:for a from 1 to 1000 do b := a^2:g := ceil(log(b+1)/log(10)):iss := true:for j from 1 to g-1 do if((b mod 2)=1) then if((floor(b/10^j) mod 2)=((-1)^(j+1)+1)/2) then iss := false:end if:else if((floor(b/10^j) mod 2)=((-1)^j+1)/2) then iss := false:end if:end if:end do: if(iss=true) then i := i+1:c[i] := b:end if:end do:q := seq(c[k],k=1..i-1); # _Sascha Kurz_, Mar 23 2002

%t altQ[n_] := n < 10 || Union[Total /@ Partition[ Mod[ IntegerDigits@n, 2], 2, 1]] == {1}; Select[ Range[0, 500]^2, altQ[#] &] (* _Giovanni Resta_, Aug 16 2018 *)

%o (Haskell)

%o a030152 n = a030152_list !! (n-1)

%o a030152_list = filter ((== 1) . a228710) a000290_list

%o -- _Reinhard Zumkeller_, Aug 31 2013

%Y Cf. A030142, A030143, A030144, A030152, A030153, A030154, A030159.

%Y Intersection of A000290 and A030141.

%K nonn,base

%O 1,3

%A _Patrick De Geest_

%E Edited by _N. J. A. Sloane_, Aug 31 2009 at the suggestion of _R. J. Mathar_

%E Offset corrected by _Reinhard Zumkeller_, Aug 31 2013