factorial without recursion