login
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