Created a non recursive implementation of fact