Go, 93 81 78 9393 90 bytes
func r(n int)(s string){s=string(n+48);if n!=1{s=r(n-1)+" "+s};println(s);return}
Current ungolfed
func r(n int) (s string) {
// Convert n to a string, we do not have to initialize s since
// we hijacked the return value.
// Numbers in the ascii table starts at 48
s = string(n | 48)
// Unless we are on our last iteration, we need previous iterations,
// a space and our current iteration
if n != 1 {
// Collect the result of previous iteration for output
s = r(n-1) + " " + s
}
println(s)
// We can use a naked return since we specified the
// name of our return value in the function signature
return
}
If we need to handle N > 9 we can use the following at 78 bytes, however it requires importing the fmt
package.
func r(n int)(s string){s=Sprint(n);if n!=1{s=r(n-1)+" "+s};Println(s);return}
If we include the import statement I'm now back at my initial 93 9292 90 bytes
import(."fmt");func"fmt";func r(n int)(s string){s=Sprint(n);if n>1{s=r(n-1)+" "+s};Println(s);return}
Test it online here: http://play.golang.org/p/BWLQ9R6ilw
The version with fmt
is here: http://play.golang.org/p/-1RmBOLpJThttp://play.golang.org/p/hQEkLvpiqt