-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_iterative_factorial.c
28 lines (26 loc) · 1.06 KB
/
ft_iterative_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_iterative_factorial.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ybouzgao <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/06 14:35:16 by ybouzgao #+# #+# */
/* Updated: 2017/11/07 13:44:41 by ybouzgao ### ########.fr */
/* */
/* ************************************************************************** */
int ft_iterative_factorial(int nb)
{
int a;
a = 1;
if (nb < 0 || nb > 12)
return (0);
else if (nb == 0 || nb == 1)
return (1);
while (nb > 1)
{
a = a * nb;
nb--;
}
return (a);
}