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!)
A329267 a(n) is the absolute difference between n and its nearest palindromic neighbor. 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,14
COMMENTS
Empirical observation: this sequence is similar to A261424 but yields the absolute difference between n and its nearest palindromic neighbor. It answers the question "How far from this number is the nearest palindrome?"
LINKS
EXAMPLE
For 0 <= n <= 9, n is palindromic so a(n) = 0.
a(10) = 10-9 = 11-10 = 1 (10 is equidistant from its two nearest palindromes).
a(11) = 0 because 11 is palindromic.
For 12 <= n <= 16, a(n) = n-11 because 11 is the nearest palindromic number.
For 17 <= n <= 22, a(n) = 22-n because 22 is the nearest palindromic number.
.
n nearest palindrome difference
-- ------------------ ----------
1 1 1-1 = 0
2 2 2-2 = 0
3 3 3-3 = 0
4 4 4-4 = 0
5 5 5-5 = 0
6 6 6-6 = 0
7 7 7-7 = 0
8 8 8-8 = 0
9 9 9-9 = 0
10 9 or 11 10-9 = 11-10 = 1
11 11 11-11 = 0
12 11 12-11 = 1
13 11 13-11 = 2
14 11 14-11 = 3
15 11 15-11 = 4
16 11 16-11 = 5
17 22 22-17 = 5
18 22 22-18 = 4
19 22 22-19 = 3
20 22 22-20 = 2
21 22 22-21 = 1
22 22 22-22 = 0
23 22 23-22 = 1
MATHEMATICA
palQ[n_] := Block[{d = IntegerDigits[n]}, d == Reverse@ d]; a[n_] := Block[{k=0}, While[! palQ[n+k] && ! palQ[n-k], k++]; k]; Array[a, 121] (* Giovanni Resta, Nov 12 2019 *)
PROG
(PARI) ispal(n) = my (d=digits(n)); d==Vecrev(d)
a(n) = for (k=0, oo, if (ispal(n-k) || ispal(n+k), return (k))) \\ Rémy Sigrist, Dec 03 2019
CROSSREFS
Sequence in context: A301534 A101916 A361979 * A100771 A234470 A113771
KEYWORD
nonn,base
AUTHOR
STATUS
approved

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 19 19:02 EDT 2024. Contains 371798 sequences. (Running on oeis4.)