-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_factorial.c
26 lines (25 loc) · 1.11 KB
/
ft_factorial.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_factorial.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ana-lda- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/26 14:50:09 by ana-lda- #+# #+# */
/* Updated: 2024/06/26 14:50:48 by ana-lda- ### ########.fr */
/* */
/* ************************************************************************** */
int ft_recursive_factorial(int nb)
{
if (nb < 0)
return (0);
if (nb == 0 || nb == 1)
return (1);
return (nb * (ft_recursive_factorial(nb - 1)));
}
/*
#include <stdio.h>
int main(void)
{
printf("%d", ft_recursive_factorial(0));
}*/