Cubix, 1212 10 bytes
*,)2I://O@
Initial version
....I:)*2,O@
Explanation
Expanded onto a cube, the code looks like this:
.* .,
.) .2
I : ) * 2/ ,/ O @ . .
. . . . . . . .
. .
. .
In this caseThe instruction pointer (IP) starts at the I
, moving east. It continues moving east until it comes across the /
mirror, which reflects it north. When the IP reaches the top of the code is linear, so it's easyit wraps around to explainthe last .
on the third line, moving south. Then it wraps to the penultimate .
on the last line, moving north. Then it reaches the /
mirror again, which reflects it east, only for the next /
to reflect it north again. This istime, the orderIP wraps to the commandspenultimate .
on the third line, and then the last .
on the last line.
The instructions are executed in the following order.
I:)*2,O@ # Explanation
I # Take input as an integer and push it to the stack
: # Duplicate the input
) # Increment one of the inputs
* # Multiply the input by input+1
2 # Push 2 to the stack
, # Integer devide the multiplication result by 2
O # Output the result
@ # End program