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/27 16:41:34 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
int ft_iterative_factorial(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);
|
|
}
|