%I #13 Aug 25 2019 02:09:35
%S 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,
%T 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,
%U 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
%N Distance from n to closest palindrome that is different from n.
%H David A. Corneth, <a href="/A309932/b309932.txt">Table of n, a(n) for n = 0..9999</a>
%H <a href="/index/Di#distance_to_the_nearest">Index entries for sequences related to distance to nearest element of some set</a>
%t a[n_] := Module[{k = 1}, While[! PalindromeQ[n + k] && ! PalindromeQ[n - k], k++]; k]; Table[a[n], {n, 0, 100}]
%o (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
%Y Cf. A002113, A100771.
%K nonn,base,look
%O 0,12
%A _Ilya Gutkovskiy_, Aug 23 2019
|