first commit
This commit is contained in:
24
C05/ex04/ft_fibonacci.c
Normal file
24
C05/ex04/ft_fibonacci.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_fibonacci.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/07/23 22:53:47 by adjoly #+# #+# */
|
||||
/* Updated: 2023/07/31 16:58:43 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_fibonacci(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
return (-1);
|
||||
if (index == 0)
|
||||
return (0);
|
||||
if (index == 1)
|
||||
return (1);
|
||||
if (index == 2)
|
||||
return (1);
|
||||
return (ft_fibonacci(index - 2) + ft_fibonacci(index - 1));
|
||||
}
|
Reference in New Issue
Block a user