It's presented as a recursive function which requires memoization and parallelism. There are 2 main approaches:
- Synchronization primitives, or
Mine is simple because I dropped the recursion. If you see a producer/consumer pattern with recursion, you probably need synchronization primitives. But if you can drop the recursion, then the consumer can know exactly how many producers he created.
An interesting sidebar is how to memoize in Go. A closure is probably the best way, but I didn't bother with that in my solution, to minimize diffs.