42/d04/ex00/ft_iterative_factorial.c

32 lines
1 KiB
C
Raw Normal View History

2016-11-20 02:20:23 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_iterative_factorial.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/10/31 15:38:54 by gtertysh #+# #+# */
/* Updated: 2016/10/31 15:38:59 by gtertysh ### ########.fr */
/* */
/* ************************************************************************** */
int ft_iterative_factorial(int nb)
{
int fac;
fac = 1;
if (nb > 12 || nb < 0)
{
return (0);
}
else
{
while (nb > 0)
{
fac *= nb;
nb--;
}
}
return (fac);
}