23 lines
1.1 KiB
C
23 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_fibonacci.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2016/10/29 15:51:02 by gtertysh #+# #+# */
|
|
/* Updated: 2016/10/29 17:46:07 by gtertysh ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
int ft_fibonacci(int index)
|
|
{
|
|
if (index < 0)
|
|
return (-1);
|
|
else if (index == 0)
|
|
return (0);
|
|
else if (index == 1)
|
|
return (1);
|
|
else
|
|
return (ft_fibonacci(index - 1) + ft_fibonacci(index - 2));
|
|
}
|