#Runic, 34 bytes
/01iR1-:0)?;{1+:
\$1<\}$q}:+1{$ '
Uncompressing the entry sequence and moving the reflectors to the other side:
>1$01iR1-:0)?;{1+:\
\}$q}:+1{$ '/
Entry sequence (>1$01i
) is fairly straight forward. Push and print 1
, push 0
, push 1
, read input and push it to the top of the stack.
At R
we enter the program's main loop (unrolled with directional control characters removed):
1-:0)?;{1+:' ${1+:}q$}
At this point the stack is [0,1,i]
where i
is the input value.
The loop subtracts 1 from the input value (1-
), compares it to greater than 0 (if true, skip terminator, else terminate; :0)?;
).
Then a series of stack manipulations ({1+:{1+:}
) and increments to result in [2,(i-1),1,1,2]
as well as printing a space (' $
). q
then concats the top two items on the stack, which is then printed (giving 12
in the output stream).
Finally the stack is rotated once more, leaving [1,2,(i-1)]
as the input to the next loop iteration.
###Bonus challenge: using two IPs? 40 bytes
>1$0iR1-:0)?;1{+:' \
> F1iU }$~?=am$?=9m/
As there's no way to clone the input to a second instruction pointer (I have thought about stack cloning, so this may be possible in the future, but the spec for it would be difficult to implement), we have to read it from the input stream twice.
Flow results in the second pointer being a step behind the first (avoiding merging) and the F
izzle lets us distinguish the two IPs, letting one print a space and the other discards it. I can't figure out a shorter way of performing this check.
However if it allowable to print two spaces as a separator it can be reduced to this (30 bytes):
>1$0iR1-:0)?;1\
> F1iU}$:+{$ '/
input: 4 4
output: 1 12 23 34
But this is an admittedly dubious answer due to how it has to take input, but 4 bytes shorter than the single IP answer, which is interesting.