mirror of
https://github.com/Ladebeze66/Piscine42.git
synced 2026-11-09 21:27:16 +01:00
Piscine42
This commit is contained in:
20
C05/ex01/ft_recursive_factorial.c
Executable file
20
C05/ex01/ft_recursive_factorial.c
Executable file
@@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_recursive_factorial.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/12/12 11:02:42 by fgras-ca #+# #+# */
|
||||
/* Updated: 2022/12/12 11:17:18 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_recursive_factorial(int nb)
|
||||
{
|
||||
if (nb < 0)
|
||||
return (0);
|
||||
if (nb == 0)
|
||||
return (1);
|
||||
return (nb * ft_recursive_factorial(nb - 1));
|
||||
}
|
||||
Reference in New Issue
Block a user