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!)
A262037 Replace the second half of digits of n with the first half in reverse order. 4
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, 22, 22, 22, 22, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 44, 44, 44, 44, 44, 44, 44, 44, 44, 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 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,3
COMMENTS
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.
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".
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.
LINKS
EXAMPLE
a(31) = 33 since the second half ("1") gets replaced by the first half ("3").
a(314) = 313 since the second half ("4") is replaced by the first half ("3"), the middle "1" being untouched.
a(3141) = 3113 since the second half (41) is replaced by the first half (31), reversed (13).
a(31415) = 31413 as above, the middle 4 being left untouched.
a(314156) = 314413. This is the first instance in these examples where a(n) differs from A261423(n), which would yield 313313 here.
MATHEMATICA
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 *)
PROG
(PARI) a(n, d=digits(n), m=sum(k=1, #d\2, d[k]*10^(k-1)))=n+m-n%10^(#d\2)
(Python)
def A262037(n):
s = str(n); h = s[:(len(s)+1)//2]; return int(h + h[-1-len(s)%2::-1])
print([A262037(n) for n in range(77)]) # Michael S. Branicky, Sep 15 2022
CROSSREFS
Sequence in context: A358386 A065649 A338830 * A262039 A354719 A340835
KEYWORD
nonn,base
AUTHOR
M. F. Hasler, Sep 08 2015
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 16:08 EDT 2024. Contains 371794 sequences. (Running on oeis4.)