As an after-thought, the function should test for the highest divisor between 1...k (or, for efficiency's sake, simply the highest of the set of integers 1...k that a given number divides out. This is the solutions I was going for (but it's late, I'm tired, and I have much work to do - which I am avoiding at the moment - so anyone who wants to mess with it feel free). You'd have to compute and store k!, and then just divide out those numbers until whatever value holding k! initially becomes 1 (then stop dividing when you multiply the next number in the sequence as well). The iterative solution is probably faster for the earlier rows, but this one doesn't grow very fast. Still the fastest for very small rows would be just to actually do the division.