init
This commit is contained in:
BIN
Correction/corC05ma/ex00/a.out
Executable file
BIN
Correction/corC05ma/ex00/a.out
Executable file
Binary file not shown.
35
Correction/corC05ma/ex00/ft_iterative_factorial.c
Normal file
35
Correction/corC05ma/ex00/ft_iterative_factorial.c
Normal file
@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_iterative_factorial.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/19 17:18:33 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/28 17:23:42 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_iterative_factorial(int nb)
|
||||
{
|
||||
int nbr_out;
|
||||
|
||||
if (nb < 0)
|
||||
return (0);
|
||||
nbr_out = 1;
|
||||
while (nb > 0)
|
||||
{
|
||||
nbr_out = nbr_out * nb;
|
||||
nb--;
|
||||
}
|
||||
return (nbr_out);
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc > 1)
|
||||
printf("%d", ft_iterative_factorial(atoi(argv[1])));
|
||||
}
|
Reference in New Issue
Block a user