Implement non-recursive factorial