-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_factorial.c
30 lines (27 loc) · 1.06 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
27
28
29
30
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_factorial.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: averemiy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/05 15:11:29 by averemiy #+# #+# */
/* Updated: 2018/04/05 15:13:28 by averemiy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_factorial(int nb)
{
int res;
if (nb > 12)
return (0);
res = 1;
if (nb < 0)
return (0);
while (nb > 0)
{
res = res * nb;
nb--;
}
return (res);
}