A131207 Nonnegative integers n such that the difference between n and its reverse is a palindrome.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 21, 22, 23, 32, 33, 34, 43, 44, 45, 54, 55, 56, 65, 66, 67, 76, 77, 78, 87, 88, 89, 98, 99, 100, 101, 102, 110, 111, 112, 120, 121, 122, 130, 131, 132, 140, 141, 142, 150, 151, 152, 160, 161, 162, 170, 171, 172, 180
Offset: 1
Examples
122 is in the sequence as the difference between 122 and its reversal (211) is 99 which is a palindrome. - _David A. Corneth_, Dec 01 2023
Links
- David A. Corneth, Table of n, a(n) for n = 1..10000
Programs
-
Java
for(i = 1; i <=1000; i++){ n = Math.abs(i - reverseNumber(i)); if(n == reverseNumber(n)){ System.out.println(i); } }
-
Maple
filter:= proc(n) local L,nL,r; L:= convert(n,base,10); nL:= nops(L); r:= add(L[i]*10^(nL-i),i=1..nL); L:= convert(abs(n-r),base,10); evalb(L = ListTools:-Reverse(L)) end proc: select(filter, [$0..1000]); # Robert Israel, Aug 26 2014
-
Mathematica
revpalQ[n_]:=Module[{diff=IntegerDigits[Abs[n-FromDigits[Reverse[ IntegerDigits[ n]]]]]},diff==Reverse[diff]]; Select[Range[ 0,400],revpalQ] (* Harvey P. Dale, Aug 22 2014 *)
-
PARI
is(n) = { my(d = abs(fromdigits(Vecrev(digits(n))) - n)); d = digits(d); d == Vecrev(d) } \\ David A. Corneth, Dec 01 2023
Extensions
Corrected by Harvey P. Dale, Aug 22 2014
Comments