42_C_PISCINE/C/c05v5/ex01/ft_recursive_factorial.c

24 lines
1.0 KiB
C
Raw Normal View History

2023-05-17 12:45:25 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_recursive_factorial.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/19 17:06:51 by cchauvet #+# #+# */
/* Updated: 2022/08/01 18:09:47 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_recursive_factorial(int nb)
{
if (nb < 0)
return (0);
if (nb == 0)
return (1);
if (nb == 1)
return (nb);
else
return (nb * ft_recursive_factorial(nb - 1));
}