for loop factorial working