Japt, 12 bytes
òV
£¯Y ¬ç +X
Works for both ascendingTakes input in either order and descending numbers, depending onalways returns the inputnumbers in ascending order. Returns, as an array of lines.
Try it online! with the -R
flag to join the array with newlines.
Explanation
Implicit input of U
and V
.
òV
£
Create inclusive range [U, V]
and map each value to...
¯Y ¬ç
The values before the current (¯Y
), joined to a string (¬
) and filled with spaces (ç
).
+X
Plus the current number. Resulting array is implicitly output.