A244552 Palindromes j such that j +- the sum of digits of j are both palindromes.
1, 2, 3, 4, 181, 262, 343, 424, 767, 848, 929
Offset: 1
Examples
181 is a palindrome, 181 + (1+8+1) = 191 is a palindrome, and 181 - (1+8+1) = 171 is a palindrome. Thus 181 is a member of this sequence.
Programs
-
Mathematica
palQ[n_]:=Module[{t=Total[IntegerDigits[n]]},AllTrue[{n,n+t,n-t}, PalindromeQ]]; Select[Range[1000],palQ] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Sep 23 2018 *)
-
PARI
rev(n)={r="";for(i=1,#digits(n),r=concat(Str(digits(n)[i]),r));return(eval(r))} for(n=1,10^7,if(rev(n)==n,dig=digits(n);s=sum(k=1,#dig,dig[k]);sm=n-s;la=n+s;if(rev(sm)==sm&&rev(la)==la,print1(n,", "))))
Comments