login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A052036
Smallest number that must be added to n to make or keep n palindromic.
3
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
OFFSET
0,13
FORMULA
a(n)=0 iff n is in A002113, otherwise a(n)=A052037(n)-1. - M. F. Hasler, Apr 26 2014
EXAMPLE
If n = 13 we need to add 9 to arrive at palindrome 22.
MATHEMATICA
snpal[n_]:=Module[{k=0, idn}, While[idn=IntegerDigits[n+k]; idn != Reverse[ idn], k++]; k]; Array[snpal, 100, 0] (* Harvey P. Dale, Nov 27 2012 *)
PROG
(PARI) a(n)=for(k=0, 9e19, is_A002113(n+k)&&return(k)) \\ For illustrative purpose only, inefficient for most large numbers. - M. F. Hasler, Apr 26 2014
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Patrick De Geest, Dec 15 1999
STATUS
approved