first commit
This commit is contained in:
22
ended/C05/ex04/ft_fibonacci.c
Normal file
22
ended/C05/ex04/ft_fibonacci.c
Normal file
@ -0,0 +1,22 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_fibonacci.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/27 18:51:47 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/27 18:51:48 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_fibonacci(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
return (-1);
|
||||
if (index == 0)
|
||||
return (0);
|
||||
if (index == 1)
|
||||
return (1);
|
||||
return (ft_fibonacci(index - 1) + ft_fibonacci(index - 2));
|
||||
}
|
Reference in New Issue
Block a user