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!)
A030147 Palindromes in which parity of digits alternates. 6

%I #24 Jul 04 2023 18:53:50

%S 0,1,2,3,4,5,6,7,8,9,101,121,141,161,181,212,232,252,272,292,303,323,

%T 343,363,383,414,434,454,474,494,505,525,545,565,585,616,636,656,676,

%U 696,707,727,747,767,787,818,838,858,878,898,909,929,949

%N Palindromes in which parity of digits alternates.

%C All terms have an odd number of digits. - _Alonso del Arte_, Jan 31 2020

%H Reinhard Zumkeller, <a href="/A030147/b030147.txt">Table of n, a(n) for n = 1..10000</a>

%H <a href="/index/Pac#palindromes">Index entries for sequences related to palindromes</a>

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

%t palQ[n_, b_:10] := (IntegerDigits[n, b] == Reverse[IntegerDigits[n, b]]); alternParQ[n_, b_:10] := (Union[BlockMap[Xor @@ # &, OddQ[IntegerDigits[n, b]], 2, 1]] == {True}); Join[Range[0, 9], Select[Range[1000], palQ[#] && alternParQ[#] &]] (* _Alonso del Arte_, Feb 02 2020 *)

%t Join[Range[0,9],Select[Range[100000],PalindromeQ[#]&&Union[Total/@Partition[Boole[ EvenQ[ IntegerDigits[ #]]],2,1]] =={1}&]] (* _Harvey P. Dale_, Jul 04 2023 *)

%o (Haskell)

%o a030147 n = a030147_list !! (n-1)

%o a030147_list = filter ((== 1) . a228710) a002113_list

%o -- _Reinhard Zumkeller_, Aug 31 2013

%o (Scala) def isPal(n: Int) = (n.toString == n.toString.reverse)

%o def alternsPar(n: Int): Boolean = {

%o val dPars = Integer.toString(n).toList.map(_ % 2 == 0)

%o val scanPars = (dPars zip dPars.tail).map{ case (x, y) => x ^ y }

%o scanPars.toSet == Set(true)

%o }

%o (0 to 9) ++: (10 to 999).filter(isPal).filter(alternsPar) // _Alonso del Arte_, Feb 02 2020

%Y Intersection of A002113 and A030141.

%Y Subsequence of A001633.

%Y Cf. A030143, A030144, A030152.

%K nonn,base

%O 1,3

%A _Patrick De Geest_

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 24 00:30 EDT 2024. Contains 371917 sequences. (Running on oeis4.)