-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_iterative_factorial.c
More file actions
31 lines (29 loc) · 1.15 KB
/
ft_iterative_factorial.c
File metadata and controls
31 lines (29 loc) · 1.15 KB
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
31
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_iterative_factorial.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: thperchi <marvin@le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/10/23 13:15:29 by thperchi #+# ## ## #+# */
/* Updated: 2018/10/23 13:17:35 by thperchi ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
int ft_iterative_factorial(int nb)
{
int x;
x = nb - 1;
if (nb > 12)
return (0);
if (nb < 0)
return (0);
if (nb == 0)
return (1);
while (x >= 1)
{
nb = x * nb;
x--;
}
return (nb);
}