login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A309932 Distance from n to closest palindrome that is different from n. 1

%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

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 06:04 EDT 2024. Contains 371906 sequences. (Running on oeis4.)