OFFSET
1,2
COMMENTS
Contains all palindromes such that the middle digit is odd (if number of digits is odd) or middle two digits are odd (if number of digits is even) and all other digits are even; also palindromes where the first and last digits are odd (but not 1) and all other digits are 9. - Robert Israel, Nov 12 2018
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
P. De Geest, World!Of Numbers
EXAMPLE
999 = 494 + 505.
MAPLE
ispali:= proc(n) local L;
L:= convert(n, base, 10);
L = ListTools:-Reverse(L)
end proc:
digrev:= proc(n) local L;
L:= convert(n, base, 10);
add(L[-i]*10^(i-1), i=1..nops(L))
end proc:
N:=5; Pals:= $0..9:
for d from 2 to N do
q:= p;
if d::even then
m:= d/2;
Pals:= Pals, seq(n*10^m + digrev(n), n=10^(m-1)..10^m-1);
else
m:= (d-1)/2;
Pals:= Pals, seq(seq(n*10^(m+1)+y*10^m+digrev(n), y=0..9), n=10^(m-1)..10^m-1);
fi
od:
Pals:= [Pals]:
select(ispali, Pals[1..-2]+Pals[2..-1]); # Robert Israel, Nov 12 2018
MATHEMATICA
palQ[n_] := Reverse[x = IntegerDigits[n]] == x; Select[Total /@ Partition[Select[Range[3500], palQ], 2, 1], palQ] (* Jayanta Basu, Jun 26 2013 *)
nextPalindrome[n_]:=Module[{k=n+1}, While[!PalindromeQ[k], k++]; k]; s={}; Do[If[PalindromeQ[n], sum =n + nextPalindrome[n]; If[PalindromeQ[sum], AppendTo[s, sum]]], {n, 0, 10000}]; s (* Amiram Eldar, Nov 10 2018 *)
Select[Total/@Partition[Select[Range[0, 5000], PalindromeQ], 2, 1], PalindromeQ] (* Harvey P. Dale, Sep 24 2021 *)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Patrick De Geest, Sep 15 1998
EXTENSIONS
a(1)=1 inserted by Alois P. Heinz, Nov 13 2018
STATUS
approved