Archived
first commit
This commit is contained in:
1 parent
1fe062c970
commit
eb6b113e51
125 files changed
+2987
No files matched your search
@@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_iterative_factorial.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/27 11:34:45 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/27 11:34:47 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_iterative_factorial(int nb)
|
||||
{
|
||||
int i;
|
||||
int result;
|
||||
|
||||
i = 1;
|
||||
result = 1;
|
||||
if (nb < 0)
|
||||
return (0);
|
||||
if (nb == 0 || nb == 1)
|
||||
return (1);
|
||||
while (i <= nb)
|
||||
{
|
||||
result = i * result;
|
||||
i++;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
Reference in new issue
Block a user