From a2ef228b981df5ad417a0e8377e1e832002a7644 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 7 Jul 2019 15:29:30 +0200 Subject: c04/c05 testing + c06 --- c05/ex01/ft_recursive_factorial.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 c05/ex01/ft_recursive_factorial.c (limited to 'c05/ex01') diff --git a/c05/ex01/ft_recursive_factorial.c b/c05/ex01/ft_recursive_factorial.c new file mode 100644 index 0000000..615cd04 --- /dev/null +++ b/c05/ex01/ft_recursive_factorial.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_recursive_factorial.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/06 17:15:10 by cacharle #+# #+# */ +/* Updated: 2019/07/06 17:18:58 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_recursive_factorial(int nb) +{ + if (nb < 0) + return (0); + if (nb == 0 || nb == 1) + return (1); + return nb * ft_recursive_factorial(nb - 1); +} -- cgit