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/ex04/ft_fibonacci.c
Executable file
20
C05/ex04/ft_fibonacci.c
Executable file
@@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_fibonacci.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/12/12 13:26:04 by fgras-ca #+# #+# */
|
||||
/* Updated: 2022/12/12 14:22:37 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_fibonacci(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
return (-1);
|
||||
if (index == 0 || index == 1)
|
||||
return (index);
|
||||
return (ft_fibonacci(index - 1) + ft_fibonacci(index - 2));
|
||||
}
|
||||
Reference in New Issue
Block a user