This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A262039 #15 Sep 10 2015 14:17:48 %S A262039 0,1,2,3,4,5,6,7,8,9,11,11,11,11,11,11,11,22,22,22,22,22,22,22,22,22, %T A262039 22,22,33,33,33,33,33,33,33,33,33,33,33,44,44,44,44,44,44,44,44,44,44, %U A262039 44,55,55,55,55,55,55,55,55,55,55,55,66,66,66,66,66,66,66,66,66,66,66,77,77 %N A262039 Nearest palindrome to n; in case of a tie choose the larger palindrome. %C A262039 In analogy to the numerical "round" function, we "round up" to the next larger palindrome A262038(n) if it is at the same distance or closer, else we "round down" to the next smaller palindrome A261423(n). See A262040 for a variant where the next smaller palindrome is chosen in case of equal distance. %e A262039 a(10) = 11 since we round up if the next smaller palindrome (here 9) is at the same distance, both 9 and 11 are here at distance 1 from n = 10. %e A262039 a(16) = 11 since |16 - 11| = 5 is smaller than |16 - 22| = 6. %e A262039 a(17) = 22 since |17 - 22| = 5 is smaller than |17 - 11| = 6. %e A262039 a(27) = 22 since |22 - 27| = 5 is smaller than |27 - 33| = 6. %e A262039 a(28) = 33 since |33 - 28| = 5 is smaller than |22 - 28| = 6, and so on. %e A262039 a(100) = 101 because we round up again in this case, where 99 and 101 both are at distance 1 from n = 100. %t A262039 palQ[n_] := Block[{d = IntegerDigits@ n}, d == Reverse@ d]; %t A262039 f[n_] := Block[{k = n}, While[Nand[palQ@ k, k > -1], k--]; k]; %t A262039 g[n_] := Block[{k = n}, While[! palQ@ k, k++]; k]; %t A262039 h[n_] := Block[{a = f@ n, b = g@ n}, Which[palQ@ n, n, (b - n) - (n - a) > 0, a, (b - n) - (n - a) <= 0, b]]; Table[h@ n, {n, 0, 73}] (* _Michael De Vlieger_, Sep 09 2015 *) %Y A262039 Cf. A002113, A261423, A262037, A262038, A262040. %K A262039 nonn,base %O A262039 0,3 %A A262039 _M. F. Hasler_, Sep 08 2015