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 A262037 #29 Jun 15 2025 17:26:21 %S A262037 0,1,2,3,4,5,6,7,8,9,11,11,11,11,11,11,11,11,11,11,22,22,22,22,22,22, %T A262037 22,22,22,22,33,33,33,33,33,33,33,33,33,33,44,44,44,44,44,44,44,44,44, %U A262037 44,55,55,55,55,55,55,55,55,55,55,66,66,66,66,66,66,66,66,66,66,77,77,77,77,77,77,77 %N A262037 Replace the second half of digits of n with the first half in reverse order. %C A262037 This is related to the "palindromic floor" and "palindromic ceiling" functions A261423 and A262038: a(n) = A261423(n) iff the first half of digits reversed does not exceed the second half of digits (without considering the middle digit in case of an odd number of digits), and a(n) = A262038(n) in the opposite case, i.e., first half of digits reversed is greater than or equal to second half of digits. %C A262037 a(n) is either equal to the palindromic floor A261423(n) (e.g., a(1234) = 1221), or to the palindromic ceiling A262038(n) (= next larger palindrome, e.g., a(1324)=1331). In this sense it can be seen as a "palindromic round" function. However, it does not always yield the closest of the two (a(1900) = 1991 but 1881 would be closer to 1900). The sequence A262040 which has this property would better merit the name of "palindromic round function". %C A262037 This simple function can be used to construct the next larger or next smaller palindrome, A261423 and A262038: indeed, if a(n) has the required property (less than or greater than n) then it is already the desired result, otherwise the result is given by a(n +- 10^k), where k is half the number of digits of n. %H A262037 Dominic McCarty, <a href="/A262037/b262037.txt">Table of n, a(n) for n = 0..10000</a> %e A262037 a(31) = 33 since the second half ("1") gets replaced by the first half ("3"). %e A262037 a(314) = 313 since the second half ("4") is replaced by the first half ("3"), the middle "1" being untouched. %e A262037 a(3141) = 3113 since the second half (41) is replaced by the first half (31), reversed (13). %e A262037 a(31415) = 31413 as above, the middle 4 being left untouched. %e A262037 a(314156) = 314413. This is the first instance in these examples where a(n) differs from A261423(n), which would yield 313313 here. %t A262037 f[n_] := Block[{d = IntegerDigits@ n}, FromDigits[Take[d, Ceiling[Length[d]/2]]~Join~Reverse@ Take[d, Floor[Length[d]/2]]]]; Table[f@ n, {n, 0, 120}] (* _Michael De Vlieger_, Sep 09 2015 *) %o A262037 (PARI) a(n,d=digits(n),m=sum(k=1,#d\2,d[k]*10^(k-1)))=n+m-n%10^(#d\2) %o A262037 (Python) %o A262037 def A262037(n): %o A262037 s = str(n); h = s[:(len(s)+1)//2]; return int(h + h[-1-len(s)%2::-1]) %o A262037 print([A262037(n) for n in range(77)]) # _Michael S. Branicky_, Sep 15 2022 %Y A262037 Cf. A002113, A261423, A262038, A262039, A262040. %K A262037 nonn,base %O A262037 0,3 %A A262037 _M. F. Hasler_, Sep 08 2015