Here is a sleepless version. The channel is still unbuffered, but this
should be OK since reading from channel is done in main().
Thus, factorial() writes the result to the channel, and main() reads it
from there. As result main() does not end before factorial() is completed.
https://play.golang.o
Jan is correct, and you should probably use a sync.WaitGroup to keep your
main() alive.
But even if you do that, you have a bigger problem. You channel is
unbuffered. That means that `d <- a` will block until someone reads from d.
Since `factorial` is the only goroutine that uses d, that line w