Use recursion, and build a dynamic hash of partial results to speed up recursion.

References

Other