27 lines
1.0 KiB
C
27 lines
1.0 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_iterative_factorial.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/07/19 17:18:33 by cchauvet #+# #+# */
|
|
/* Updated: 2022/07/25 17:28:28 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
int ft_iterative_factoriel(int nb)
|
|
{
|
|
int nbr_out;
|
|
|
|
if (nb < 0)
|
|
return (0);
|
|
nbr_out = 1;
|
|
while (nb > 0)
|
|
{
|
|
nbr_out = nbr_out * nb;
|
|
nb--;
|
|
}
|
|
return (nbr_out);
|
|
}
|