first commit
This commit is contained in:
20
ended/C05/ex01/ft_recursive_factorial.c
Normal file
20
ended/C05/ex01/ft_recursive_factorial.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_recursive_factorial.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <ajoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/27 14:51:29 by ajoly #+# #+# */
|
||||
/* Updated: 2022/08/01 13:39:06 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_recursive_factorial(int nb)
|
||||
{
|
||||
if (nb < 0)
|
||||
return (0);
|
||||
if (nb == 1 || nb == 0)
|
||||
return (1);
|
||||
return (nb * ft_recursive_factorial(nb - 1));
|
||||
}
|
Reference in New Issue
Block a user