32 lines
1 KiB
C
32 lines
1 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* 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);
|
||
|
}
|