A262037 Replace the second half of digits of n with the first half in reverse order.
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
Offset: 0
Examples
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.
Links
- Dominic McCarty, Table of n, a(n) for n = 0..10000
Programs
-
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 *)
-
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
Comments