login
A309932
Distance from n to closest palindrome that is different from n.
1
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 11, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 11, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 11, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 11, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 11, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 11, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 11, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 2, 1
OFFSET
0,12
MATHEMATICA
a[n_] := Module[{k = 1}, While[! PalindromeQ[n + k] && ! PalindromeQ[n - k], k++]; k]; Table[a[n], {n, 0, 100}]
PROG
(PARI) a(n)={my(ispal=v->v==Vecrev(v)); for(k=1, oo, if(ispal(digits(n+k)) || ispal(digits(n-k)), return(k)))} \\ Andrew Howroyd, Aug 23 2019
CROSSREFS
Sequence in context: A125932 A175793 A244789 * A363968 A058886 A236858
KEYWORD
nonn,base,look
AUTHOR
Ilya Gutkovskiy, Aug 23 2019
STATUS
approved