%I #25 Sep 15 2022 02:18:34
%S 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 22,22,22,22,33,33,33,33,33,33,33,33,33,33,44,44,44,44,44,44,44,44,44,
%U 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 Replace the second half of digits of n with the first half in reverse order.
%C 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 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 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.
%e a(31) = 33 since the second half ("1") gets replaced by the first half ("3").
%e a(314) = 313 since the second half ("4") is replaced by the first half ("3"), the middle "1" being untouched.
%e a(3141) = 3113 since the second half (41) is replaced by the first half (31), reversed (13).
%e a(31415) = 31413 as above, the middle 4 being left untouched.
%e a(314156) = 314413. This is the first instance in these examples where a(n) differs from A261423(n), which would yield 313313 here.
%t 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 (PARI) a(n,d=digits(n),m=sum(k=1,#d\2,d[k]*10^(k-1)))=n+m-n%10^(#d\2)
%o (Python)
%o def A262037(n):
%o s = str(n); h = s[:(len(s)+1)//2]; return int(h + h[-1-len(s)%2::-1])
%o print([A262037(n) for n in range(77)]) # _Michael S. Branicky_, Sep 15 2022
%Y Cf. A002113, A261423, A262038, A262039, A262040.
%K nonn,base
%O 0,3
%A _M. F. Hasler_, Sep 08 2015