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

22 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/07/26 16:55:09 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_recursive_factorial(int nb)
{
if (nb < 0)
return (0);
if (nb == 1)
return (nb);
else
return (nb * ft_recursive_factorial(nb - 1));
}