g | x | w | all
Bytes Lang Time Link
007Pip250826T210448ZDLosc
032tinylisp 2230112T041936ZDLosc
003Thunno 2 J230610T161342ZThe Thon
nanFig230119T211623ZSeggan
010Pip230118T174817ZBaby_Boy
022Julia 1.0230112T201853ZAshlin H
018J230112T215614ZJonah
nan230112T171415ZThe Thon
090Go230112T160411Zbigyihsu
012Ly230112T093020Zcnamejj
036Arturo230112T055150Zchunes
005Pyt230112T010606ZKip the
004Vyxal221012T061443ZDialFros
018Braingolf v0.7170530T123902ZMayube
009MATL170530T113541ZSuever
032Zsh190403T013340ZGammaFun
052Java 8190308T225749ZBenjamin
005Stax190315T210844Zrecursiv
047Ink190315T192715ZSara J
030Mouse2002190315T041933ZMooseOnT
026APLNARS190315T175924Zuser5898
017dc190315T171854ZSophia L
010APL Dyalog Unicode190309T201228Zvoidhawk
044Kotlin190309T202943Zsnail_
054Common Lisp181106T181811ZRenzo
050Kotlin190307T133815ZJ00LZ
00505AB1E170530T103415ZEmigna
041Forth gforth181107T162344Zreffu
005MathGolf181107T001604ZJo King
008Japt P170530T131315ZOliver
006Japt mP181106T174715ZShaggy
053C# .NET Core181106T184809ZMeerkat
016K ngn/k181106T182639ZThaufeki
009braingasm170610T162535Zdaniero
048LOGO170610T154340Zuser2027
051Python 3170610T145036ZLeaky Nu
019Röda170530T112754Zuser4180
043C gcc170610T144311ZLeaky Nu
037Powershell170530T135208ZDanko Du
015><>170531T151716ZSok
035R170530T112827Zuser2390
022Perl 5170601T033831ZChris
052Mathematica170530T172427ZMichael
047Haskell170530T143137ZDan Ambr
015Hexagony170531T145639ZSok
071Whitespace170531T134730ZEphphath
025Bash170530T120915Zmarcosm
067Python 2170530T224608ZMikhail
046Python 2170530T104311Zuser4594
017Cubix170530T201227ZGiuseppe
037R170530T195133Zshadowta
018QBIC170530T105107Zsteenber
005Jelly170530T164331ZDennis
020Retina170530T161414ZNeil
020V170530T125945Znmjcman1
061Java170530T152929Zcheemche
nan170530T150930ZBrad Gil
009Pyke170530T150433ZBlue
043Scala170530T144752ZPhoenix
030JavaScript ES6170530T104059ZArnauld
039Python 2.7170530T141221ZDat
006Jelly170530T140335Zsteenber
029Octave170530T140440Zrahnema1
030AWK170530T111104Zjmriego
052Clojure170530T134358ZNikoNyrh
029PHP170530T105301Zuser6395
nan170530T112607Zbartavel
007Pyth170530T115150ZJakube
028Perl 5170530T113814ZDom Hast
012CJam170530T105352ZLuis Men
009Brachylog170530T111059ZFatalize
041R170530T112138ZJAD
029Ruby170530T110309ZG B
022Aceto170530T111016ZL3viatha
032Mathematica170530T105327ZZaMoC
010CJam170530T110116ZMartin E
061Clojure170530T104501Zcliffroo
009Actually170530T103846Zuser4594

Pip, 7 bytes

UEN R,a

Attempt This Online!

Explanation

UEN R,a
     ,a  Range(a) (numbers from 0 up through a-1)
    R    Reverse
 EN      Enumerate, replacing each value with an [index; value] pair (zero-based)
U        Increment all values
         Concatenate together and autoprint (implicit)

This is only the second time I've used the EN operator, despite the fact that it's been around since 2015.

tinylisp 2, 46 32 bytes

(\(N)(} ,(m u({ ,(z(1to N)(to1 N

An anonymous function that takes an integer and returns a string. Try It Online!

Explanation

(\(N)(} ,(m u({ ,(z(1to N)(to1 N))))))
(\                                   ) ; Lambda function
  (N)                                  ; that takes an integer N:
                 (z              )     ;  Zip together these two lists:
                   (1to N)             ;   Numbers from 1 to N
                          (to1 N)      ;   Numbers from N to 1
             ({ ,                 )    ;  Right fold on list/string concatenation
         (m u                      )   ;  Map unparse (convert to string) to each number
     (} ,                           )  ;  Left fold on list/string concatenation

The reason for the different folds is that right fold is more efficient, but by default it starts with an empty list, which when concatenating strings would make the result a list of charcodes instead of a string. Left-folding strings, by contrast, results in a string.

Thunno 2 J, 3 bytes

RḲI

Attempt This Online!

Explanation

RḲI  # Implicit input       ->  4
R    # Range: push [1..n]   ->  [1,2,3,4]
 Ḳ   # Bifurcate this list  ->  [1,2,3,4]  [4,3,2,1]
  I  # Interleave           ->  [1,4,2,3,3,2,4,1]
     # Join and output      ->  "14233241"

Fig, \$6\log_{256}(96)\approx\$ 4.939 bytes

OYax$a

Try it online!

OYax$a
 Y     # Interleave
  ax   # [1, n]
    $a # With [1, n] reversed
O      # Join

Pip, 10 bytes

-2 bytes thanks to DLosc!

Y\,ayWVRVy

Try It Online!


Pip, 12 bytes

(Y++,a)WVRVy

How?

(Y++,a)WVRVy  : One arg(integer n)
     a        : First arg
    ,         : Inclusive range from 1
  ++          : Increment
 Y            : Yank
         RV   : Alias for unary reverse
           y  : Yanked range
       WV     : Weave two iterables together, alternating their items

Try It Online!

Julia 1.0, 33 22 bytes

~x=join([1:x x:-1:1]')

Try it online!

  1. The forward and reverse sequences are collected from ranges.
  2. This method of interleaving arrays in Julia can be adapted for code golf.
  3. The print command is vectorized with the "dot" operator so that no delimiters are shown.

J, 18 bytes

[:;],.&<&":&>:&i.-

Try it online!

Thunno J, \$ 10 \log_{256}(96) \approx \$ 8.23 bytes

R1+DrsZZ.J

Explanation

R1+DrsZZ.J  # Implicit input                  STACK (example for n=10)
R1+         # range(0, n) + 1                 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
   Dr       # Duplicate and reverse           [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
     sZZ    # Swap and zip together           [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]
        .J  # Join each inner list            ['110', '29', '38', '47', '56', '65', '74', '83', '92', '101']
            # J flag joins the final list     '1102938475665748392101'
            # Implicit output

Screenshot

Screenshot

Go, 90 bytes

import."fmt"
func f(n int)(o string){for i:=1;i<=n;i++{o+=Sprintf("%d%d",i,n-i+1)};return}

Attempt This Online!

Ly, 12 bytes

Rsrp[ul,s`u]

Try it online!

This one generates the 1..N series on the stack, and it generates the N..1 numbers by manipulating an accumulator on the backup cell.

R             - Generate range of 0..N (where N is from STDIN)
 s            - Save the upper limit to the backup cell
  rp          - Reverse the stack, delete the "0"
    [      ]  - While the stack isn't empty
     u        - Print next number in the range
      l,s     - Load backup cell, decrement and save
         `u   - Increment and print

Arturo, 36 bytes

$[n][""loop 1..n'x->~"|n-x-1||x|"++]

Try it

$[n][             ; a function taking an argument n
  ""              ; place an empty string on the stack
  loop 1..n'x->   ; foreach x in 1 to n...
    ~"|n-x-1||x|" ; interpolate x and n-x-1 into a string
    ++            ; append it to the string on the stack
]                 ; end function

Pyt, 5 bytes

řĐ↔Žǰ

Try it online!

ř          implicit input (n); push [1,2,...,n]
 Đ         duplicate top of stack
  ↔        flip the array at the top of the stack
   Ž       interleave the two arrays
    ǰ      join the contents of the array to create a string; implicit print

Vyxal, 5 4 bytes

ɾḂYṅ

Try it Online!

Explained

ɾḂYṅ
ɾ     # range of [1,input+1]
 Ḃ    # dupe and reverse
   Y  # interleave
    ṅ # join with no spaces

Braingolf v0.7, 18 bytes

VR.MUvU&,R{vMR}>&_

Try it online!

Explanation:

VR.MUvU&,R{vMR}>&_  Implicit input of n to stack
VR                  Create new stack then return to main
  .M                Duplicate n and move duplicate to new stack
    U               Replace stack with 1-n, where n is last item on stack
     vU             Replace 2nd stack with 1-n
       &,           Reverse second stack
         R          Return to main
          {   }     Map loop, runs for each item in the stack
           vMR      Move to next stack, move last item to main stack
               >    Cleanup after loop
                &_  Print all items in stack with no delimiter

MATL, 13 11 9 bytes

2 bytes saved thanks to @Luis

:tPv1eVXz

Try it at MATL Online

Explanation

        % Implicitly grab input as a number, N
:       % Create an array from 1..N
tP      % Create a reversed copy
v       % Vertically concatenate the two
1e      % Reshape it into a row vector
V       % Convert to a string
Xz      % Remove whitespace and implicitly display

Zsh, 32 bytes

repeat $1 printf $[++i]$[$1+1-i]

Try it online!

I like trying to beat Bash+coreutils with pure zsh, but sadly that is not the case here.


Cooler, but one byte longer (33 bytes):

a=({$1..1})
<<<${(j::)${(n)a}:^a}

Try it online!

Java 8, 53 52 bytes

n->{for(int i=1;n>0;System.out.print(n--+""+i++));};

Try it online!

-1 bytes thanks to Sara J!

Stax, 5 bytes

çK^↑Ñ

Run and debug it

Ink, 47 bytes

=f(n)
~temp i=n
-(l)
~i--
{n-i}{1+i}{i:->l}->->

Try it online!

Mouse-2002, 32 30 bytes

-2 moved conditional to start of loop (z.^ ... ) instead of (... z.0>^)

?n:n.z:(z.^a.1+a:a.!z.!z.1-z:)

Try it online!

Explanation:

?n:                                 ~ get input and store in n
   n.z:                             ~ copy n into z
       (z.^                         ~ stop if z equals 0
           a.1+a:                   ~ add 1 to a
                 a.!                ~ print a
                    z.!             ~ print z
                       z.1-z:)      ~ substract 1 from z

APL(NARS), 13 chars, 26 bytes

{∊k,¨⌽k←⍕¨⍳⍵}

How to use & test:

  f←{∊k,¨⌽k←⍕¨⍳⍵}
  f 1
11
  f 26
12622532442352262172081991810171116121513141413151216111710189198207216225234243252261

dc, 17 bytes

[znddn1-d0<M]dsMx

Try it online!

APL (Dyalog Unicode), 10 bytesSBCS

(∊⍪,⌽)⍕¨∘⍳

Try it online!

Explanation:

(∊⍪,⌽)⍕¨∘⍳  ⍝ Monadic function train
       ⍕¨∘⍳  ⍝ Generate integers from 1 to input, convert each to string
             ⍝ Call this vector "X"
  ⍪          ⍝ "Table" X, making a single-column matrix
   ,⌽       ⍝ Reverse X and concatenate it with the above table
             ⍝ This results in a two-column matrix with integers from
             ⍝ 1 to N and N to 1 side-by-side
 ∊           ⍝ "Enlist" the above - left-to-right, top-to-bottom,
             ⍝ recursively concatenate all items in the matrix

Kotlin, 44 bytes

{n->(1..n).joinToString(""){"$it${n-it+1}"}}

{n->                                          // n is Int input
    (1..n)                                    // range from 1 to end
          .joinToString("")                   // join items with no separator
                           {                  // transform by
                            "$it${n-it+1}"    // current number and number from end of range
                                          }}  

Lambda that takes an Int and returns a String.

Try it online!

Common Lisp, 63 54 bytes

(lambda(n)(dotimes(i n)(format t"~a~a"(1+ i)(- n i))))

Try it online!

Kotlin, 52 50 bytes

fun g(e:Int)=(1..e).forEach{print("$it${e-it+1}")}

Try it online

Older version, the one above also prints it, the one below produces a string.

fun y(n:Int)=(1..n).joinToString(""){"$it${n-it+1}"}

Try it online!

05AB1E, 6 5 bytes

Saved a byte using the new interleave built-in as suggested by rev

LÂ.ιJ

Try it online!

Explanation

L        # range [1 ... input]
 Â       # create a reversed copy
  .ι     # interleave the lists
    J    # join

Forth (gforth), 41 bytes

: f 1+ dup 1 do i 1 .r 1- dup 1 .r loop ;

Try it online!

Explanation

Loops from 1 to n and outputs the index as well as n-index in a right-aligned space of size 1 (forces no space after output)

Code Explanation

: f               \ start new word definition
  1+ dup 1        \ set up arguments to loop from 1 to n
  do              \ start loop
    i 1 .r        \ output the index in a right-aligned space of size 1
    1- dup        \ subtract 1 from current value of n and duplicate
    1 .r          \ output new n in right-aligned space of size 1
  loop            \ end loop
;                 \ end word definition

MathGolf, 5 bytes

{îkï-

Try it online!

Explanation:

{      Run a for loop over implicit input
 î     Push 1 based index of loop
  k    Push inputted number
   ï-  Subtract 0 based index of loop
       Implicitly output all this joined together

Japt -P, 11 8 bytes

Saved 2 byte thanks to @Shaggy

õ í1õU)c

Try it online!

Explanation:

õ í1õU)c
õ              Range [1...Input]
  í            Pair with:
   1õU           Range [Input...1]  
      )c       Flatten   
-P             Join into a string  

Japt -mP, 8 6 bytes

°Us+N´

Try it

           :For each U in the range [0,input)
°U         : Prefix increment U
  s        : Convert to a string
   +       : Append
    N´     :  Postfix decrement the (singleton) array of inputs
           :Implicitly join and output

C# (.NET Core), 53 bytes

a=>{for(int i=0;++i<=a;)Console.Write(i+""+(a-i+1));}

Try it online!

Uses an Action delegate to pull in the input and not require a return.

Ungolfed:

a => {
    for(int i = 0; ++i <= a;)           // initialize i and increment until a
        Console.Write(i + "" + (a - i + 1));    // output i and "inverse" of i
                                                    // empty string required to set as string
                                                    // parentheses required because C# is dumb and can't figure out what a minus sign is supposed to do without them
}

K (ngn/k), 16 bytes

{,//$r,'|r:1+!x}

Try it online!

braingasm, 9 bytes

;[>+:<:-]

Simple: Read a number from stdin to the current cell; While the current cell is not zero, go to next cell (initially 0), increase it, output its value, go back, output that value and decrease it.

LOGO, 48 bytes

to f :n
for[i 1 :n][(type :i :n+1-:i)]show "
end

Define a function f that when invoke with parameter = number n, print the result string.

Python 3, 51 bytes

lambda n:''.join("%d%d"%(x+1,n-x)for x in range(n))

Try it online!

Port of Mego's Python 2 answer.

Röda, 21 19 bytes

{seq 1,_<>seq _1,1}

Try it online!

This is an anonymous function that takes input from the stream.

Explanation

{seq 1,_<>seq _1,1}               Anonymous function, takes integer n from the stream
        <>                        Interleave
 seq 1,_                            the range 1 .. n with
          seq _1,1                  the range n .. 1

C (gcc), 43 bytes

a;f(n){for(a=1;n;a++)printf("%d%d",a,n--);}

Try it online!

Powershell, 37 bytes

param($n)-join(1..$n|%{$_,($n-$_+1)})

><>, 16 12+3 = 19 15 bytes

l:n}:n1-:?!;

Input is expected on the stack, so +3 bytes for the -v flag.

Thanks to @TealPelican for pointing out a very clever way to save 4 bytes by using the size of the stack itself - on the first iteration it'll be 1, then 2, then 3... That way, the first number in each pair manages itself, no manual incrementing required!

Previous version:

1:n1+$:n1-:?!;$!

Try it online!

R, 35 bytes

n=scan();cat(rbind(1:n,n:1),sep="")

Try it online

rbind(1:n,n:1) creates a 2 row matrix with 1 to n in the first row and n to 1 in the second. The cat function collapses this matrix, reading down each column.

Perl 5, 25 21 + 1 = 26 22 bytes

Takes input from stdin, without a trailing newline.

Runs with the -n flag:

print++$x.$_--while$_

4 bytes saved thanks to Dada.

Mathematica, 52 bytes

As a traditional function:

f[x_] := StringJoin[ToString /@ Riffle[Range[x], Reverse[Range[x]]]]

As an anonymous function

(x = Range[#]; StringJoin[ToString /@ Riffle[x, Reverse[x]]]) &

As a code block that accepts the input in the variable n

x = Range[n]; StringJoin[ToString /@ Riffle[x, Reverse[x]]]

The code is pretty simple -- generate the list of integers with Range[], interleave this list (using Riffle[]) with a copy of the list that has been reversed, then convert all the integers to strings and concatenate them with StringJoin[].

Could have done it in 30 bytes if we were allowed to leave the answer in the form of a list (thus, {1,4,2,3,3,2,4,1} rather than "14233241"). Also, in the hypothetical Mthmtca with short command names it would have been something like 21 bytes.

Performance is tolerable for n <= 1,000,000. I didn't test past that.

Haskell, 65 48 47 bytes

1 byte saved thanks to Laikoni:

f n=show=<<(\(l,r)->[l,r])=<<zip[1..][n,n-1..1]

6 bytes saved thanks to nimi:

f n=show=<<(\(l,r)->[l,r])=<<zip[1..n][n,n-1..1]

Previous answer and explanation:

f n=concatMap show$concatMap(\(l,r)->[l,r])(zip[1..n][n,n-1..1])

There's already a better Haskell answer here, but I'm new to both Haskell and code golfing, so I may as well post it :)

This function zips the list [1..n] with its reverse, resulting in a list of tuples.

[(1,n),(2,n-1),(3,n-2)..(n,1)]

Then it uses concatMap to map a lambda to this list of tuples that results in a list of lists...

[[1,n],[2,n-1],[3,n-2]..[n,1]]

...and concatenates it.

[1,n,2,n-1,3,n-2..n,1]

Then a final concatMap maps show to the list and concatenates it into a single string.

f 26 "12622532442352262172081991810171116121513141413151216111710189198207216225234243252261"

Hexagony, 15 bytes

{?\"!\{$.(.@).!

Embiggened:

   { ? \
  " ! \ {
 $ . ( . @
  ) . ! .
   . . .

Try it online!

Whitespace, 71 bytes

   
 
 	
		 
 			
  
 
	   	
	    
 	
 	 
	 
 	
 	   	
	  	 
 
	 	

 


Try it online!

Explanation

sssn  ; push 0 - seed the stack with 0 (this will be our 1->n counter, a)
sns   ; dup
tntt  ; getnum - read n (stored on the heap)
sns   ; dup
ttt   ; retr - pull n onto the stack (this will be our n->1 counter, b)
nssn  ; label 'loop'
snt   ; swap - bring a to the top
ssstn ; push 1
tsss  ; add - increment a
sns   ; dup
tnst  ; putnum - output a as a number
snt   ; swap - bring b to the top
sns   ; dup
tnst  ; putnum - output b as a number
ssstn ; push 1
tsst  ; sub - decrement b
sns   ; dup
ntstn ; jez 'exit' if b is 0
nsnn  ; jmp 'loop'

The first couple of instructions are needed to set up the stack correctly, Whitespace's input commands write to the heap so we need to copy b (the input value) back onto the stack. We start with a = 0 since it is shorter to declare 0 instead of 1 (saves a byte) and we only need to reorder the increment instruction to cope. After that we just loop and increment a, output a, output b, decrement b, until b reaches 0 (checked after the decrement).

Bash, 25 bytes

printf %s`seq $1 -1 1|nl`

Try it online!

Prints decreasing sequence, number lines increasing and printf joins lines

Space delimited, 20 bytes : seq $1 -1 1|nl|xargs

Python 2, 67 bytes

A simple one, just for the collection :)

n=input()+1
i=1
s=""
while i<n:
    s+=`i`+`n-i`
    i+=1
print s

Python 2, 46 bytes

lambda n:''.join(`x+1`+`n-x`for x in range(n))

Thanks to ovs for 4 bytes

Try it online!

Explanation:

lambda n:''.join(`x+1`+`n-x`for x in range(n))
lambda n:                                      # anonymous lambda taking one parameter n
                 `x+1`+`n-x`                   # `x` is repr(x) which is equivalent to str(x) for integers less than INT_MAX
                            for x in range(n)  # integers x in [0, n)

Cubix, 17 bytes

....1I>sO)su.@?(O

Try it online!

cubified:

    . .
    . .
1 I > s O ) s u
. @ ? ( O . . .
    . .
    . .

Pushes 1, reads in the input (I), then enters the loop which swaps the top of the stack, outputs it, increments, swaps, outputs the top of the stack, decrements, and stops if the top of the stack is 0.

R, 43 39 37 bytes

This is an anonymous function.

function(n)cat(rbind(1:n,n:1),sep="")

It's 35 bytes if I use pryr::f() like in the other answer:

pryr::f(cat(rbind(1:n,n:1),sep=""))

but needs to be installed (Enter install.packages("pryr") in the R console).

QBIC, 18 bytes

[:|Z=Z+!a$+!b-a+1$

Explanation

[:|       FOR a = 1 to n
Z=Z+      Add to Z$ 
!b$+      a cast of the loop counter as string
!b-a+1$   and a cast of (n+1) minus the loop counter to string
          Z$ is printed implicitly at the end of QBIC

Jelly, 5 bytes

RṚĖVV

Try it online!

How it works

RṚĖVV  Main link. Argument: n

R      Range; yield [1, ..., n].
 Ṛ     Reverse; yield [n, ..., 1].
  Ė    Enumerate; yield [[1, n], ..., [n, 1]].
   V   Eval; convert each flat array to a string, interpret it as a Jelly program,
       and yield the output. This concatenates the integers in each pair, yielding
       a flat array of integers
    V  Repeat the previous step, concatenating the intgegers from before.

Retina, 20 bytes

.+
$*__
\B
$.`$.'
_

Try it online! Includes test cases. Explanation: Each pair of numbers sums to n+1, so we convert n to unary and add 1. Then, we match between each pair of _s, counting the number of _s to the left and right. This generates the pairs of numbers. Finally we delete the _s now that they've served their purpose.

V, 20 bytes

ywo1@"­ñykPjñkògJ

Try it online!

Explain:

yw                    ' Copy the input number (for looping later)
  o1                 ' Insert a 1 under the input (on a newline)
     @"               ' [Copy register] number of times
       ­ñ      ñ       ' Do the thing inside of this loop
        ykP           ' Copy the current line and line above it, and paste above both
           j        ' decrement the current (top) number, and increment the one below
               k      ' Go to the top line
                ògJ   ' recursively join all of the lines

Java 61 bytes

(int n)->{for(int i=0;i<n;System.out.print(i+1+""+(n-i++)));}

Perl 6, 20 bytes

{[~] 1..*Z~($_...1)}

Test it

With an input of 100000 this takes roughly 10 seconds, including compilation and printing the output.

Expanded:

{                # bare block lambda with implicit parameter 「$_」

  [~]            # reduce using concatenation operator 「&infix:«~»」
                 # (shorter than 「join '',」)

    1 .. *       # Range from 1 to infinity

    Z~           # zip using concatenation operator

    ( $_ ... 1 ) # deduced sequence starting at the input
                 # going down to 1
}

The Z~ needs the ~ because otherwise it generates a list of lists which will stringify with spaces.

There is no need to limit the Range starting at 1, because Z stops when any of the input lists run out.
This saves two bytes (a space would be needed after $_)

Pyke, 9 bytes

SD_],sm`s

Try it here!

Scala, 43 bytes

It's not the best but it's my first code golf.

n=>1.to(n).foldLeft("")((s,x)=>s+x+(n-x+1))

JavaScript (ES6), 30 bytes

f=(n,k=1)=>n?f(n-1,k+1)+n+k:''

How?

This is pretty straightforward but it's worth noting that the string is built from tail to head. An empty string at the beginning is appended last and allows the coercion of the final result to a string to happen.

Below is the detail of the recursion for f(4):

f(4) =                                            // initial call
f(4, 1) =                                         // applying the default value to k
f(3, 2) + 4 + 1 =                                 // recursive call #1
(f(2, 3) + 3 + 2) + 4 + 1 =                       // recursive call #2
((f(1, 4) + 2 + 3) + 3 + 2) + 4 + 1 =             // recursive call #3
(((f(0, 5) + 1 + 4) + 2 + 3) + 3 + 2) + 4 + 1 =   // recursive call #4
((('' + 1 + 4) + 2 + 3) + 3 + 2) + 4 + 1 =        // n = 0 --> end of recursion
'' + 1 + 4 + 2 + 3 + 3 + 2 + 4 + 1 =              // final sum
'14233241'                                        // final result

Test cases

f=(n,k=1)=>n?f(n-1,k+1)+n+k:''

console.log(f(1))
console.log(f(4))
console.log(f(26))
console.log(f(100))

Python 2.7, 39 bytes

x=''.join(`i+1`+`n-i`for i in range(n))

Jelly, 6 bytes

RżU$FV

Try it online!

Explanation:

         Example: n = 6
R        Create a range from 1 to n             [1, 2, 3, 4, 5, 6]
  U$     and a reversed copy of that same range [6, 5, 4, 3, 2, 1]
 ż       and interleave them                    [ [1, 6], [2, 5, ... ]
    F    Flatten the list                       [1, 6, 2, 5, 3, 4 ...]
     V   And Eval: Jelly code consisting of only numbers would simply print those numbers,

Octave, 29 bytes

@(n)printf("%d",[1:n;n:-1:1])

Try it online!

AWK, 34 30 bytes

{for(i=1;i<=$1;i++)printf i$1-i+1}

{for(;i<$1;i++)printf i+1$1-i}

Try it online!

Clojure, 52 bytes

#(apply str(mapcat(fn[i][(inc i)(- % i)])(range %)))

Concatenates pair-wise integers (head and tail of the seq).

PHP, 36 35 29 bytes

for(;$argn;)echo++$i,$argn--;

Saved one byte thanks to Jörg Hülsermann.
Saved six bytes thanks to Christoph.

-5 thanks to Ørjan Johansen

Haskell, 33 bytes

f n=do a<-[1..n];[a,n-a+1]>>=show

Try it online!

Pyth, 7 bytes

jksC_BS

Try it online: Demonstration

Explanation:

jksC_BSQ   implicit Q (=input number) at the end
      SQ   create the range [1, ..., Q]
    _B     bifurcate by inversion, this gives [[1, ..., Q], [Q, ..., 1]]
  sC       zip and flatten result
jk         join to a string

Perl 5, 28 bytes

27 bytes code + 1 byte for -a.

map{print$_,"@F"+1-$_}1..$_

Try it online!

CJam, 13 12 bytes

1 byte removed thanks to Martin Ender

ri:X{_)X@-}%

Try it online!

Explanation

ri               e# Read integer n
  :X             e# Copy n into variable X
     {     }%    e# Map over the array [0 1 2 ... n-1]
      _          e# Duplicate
       )         e# Add 1
        X        e# Push n
         @       e# Rotate
          -      e# Subtract

Brachylog, 10 9 bytes

⟦₁g↔ᶻczcc

Try it online!

Explanation

⟦₁           [1, …, Input]
  g↔ᶻc       [[1, …, Input],[Input, …, 1]]
      z      Zip
       cc    Concatenate twice

R, 41 bytes

pryr::f(for(i in 1:x){cat(i);cat(x-i+1)})

pryr::f() creates a function that takes one input. Loops over 1:x and prints each element of 1:x along with each element of x:1. Prints to STDOUT.

Ruby, 29 bytes

->n{n.times{|x|$><<x+1<<n-x}}

Explanation:

->n{n.times{|x|                # x in range [0..n-1]
               $><<            # output on console
                   x+1<<n-x}}  # x+1, then n-x

Try it online!

Aceto, 25 22 bytes

)&
pX`=
(pl0
id@z
r}Z)

Explanation:

We read an integer and put it on two stacks.

id
r}

On one, we call range_up (Z), on the other range_down (z), then we set a catch mark to be able to return to this place later:

  @z
  Z)

We then check if the current stack is empty and exit if so:

 X`=
  l0

Otherwise, we print from both stacks and jump back to the catch mark:

)&
p
(p

Mathematica, 36 32 bytes

Row@Riffle[x=Range@#,Reverse@x]&

thanks Martin

CJam, 10 bytes

ri,:)_W%]z

Try it online!

Explanation

ri   e# Read input and convert to integer N.
,    e# Turn into range [0 1 ... N-1].
:)   e# Increment to get [1 2 ... N].
_W%  e# Duplicate and reverse the copy.
]    e# Wrap both in an array to get [[1 2 ... N] [N ... 2 1]]
z    e# Transpose to get [[1 N] [2 N-1] ... [N-1 2] [N 1]]
     e# This list is printed implicitly at the end of the program,
     e# but without any of the array structure (so it's essentially flattened,
     e# each number is converted to a string and then all the strings
     e# are joined together and printed).

Clojure, 61 bytes

#(let[a(range 1(+ 1 %))](apply str(interleave a(reverse a))))

Literally does what is asked. I believe it can be outgolfed by a less trivial solution.

See it online

Actually, 9 bytes

R;R@Z♂iεj

Try it online!, or run all test cases

Explanation:

R;R@Z♂iεj
R          range(1, n+1)
 ;R        duplicate and reverse
   @Z      swap and zip
     ♂i    make 1D
       εj  join with empty string