42_C_PISCINE/C/c05v2/ex00/ft_iterative_factorial.c

27 lines
1.0 KiB
C
Raw Permalink Normal View History

2023-05-17 12:45:25 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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);
}