1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
42-2nd-piscine/C05/ex04/ft_fibonacci.c
2023-08-03 23:16:27 +02:00

25 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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));
}