cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A046497 Palindromes expressible as sum of 2 consecutive palindromes.

Original entry on oeis.org

1, 3, 5, 7, 9, 11, 33, 55, 77, 99, 121, 212, 232, 252, 272, 292, 393, 414, 434, 454, 474, 494, 595, 616, 636, 656, 676, 696, 797, 818, 838, 858, 878, 898, 999, 2112, 2332, 2552, 2772, 2992, 3993, 4114, 4334, 4554, 4774, 4994, 5995, 6116, 6336, 6556, 6776, 6996, 7997, 8118, 8338, 8558
Offset: 1

Views

Author

Patrick De Geest, Sep 15 1998

Keywords

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

Examples

			999 = 494 + 505.
		

Crossrefs

Cf. A002113.

Programs

  • 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 *)

Extensions

a(1)=1 inserted by Alois P. Heinz, Nov 13 2018