Problem 15: Non-recursive factorial, so we can handle, say a 10000x10000 grid without stack overflow.