aboutsummaryrefslogtreecommitdiff
path: root/c05/ex04
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-07-07 15:29:30 +0200
committerCharles <sircharlesaze@gmail.com>2019-07-07 15:29:30 +0200
commita2ef228b981df5ad417a0e8377e1e832002a7644 (patch)
tree32827b5be808bf3123d46856bb753fc190fd3611 /c05/ex04
parent79f8ba0b777f3361002ed2ae0c6c6f8f353ca731 (diff)
downloadpiscine-a2ef228b981df5ad417a0e8377e1e832002a7644.tar.gz
piscine-a2ef228b981df5ad417a0e8377e1e832002a7644.tar.bz2
piscine-a2ef228b981df5ad417a0e8377e1e832002a7644.zip
c04/c05 testing + c06
Diffstat (limited to 'c05/ex04')
-rw-r--r--c05/ex04/ft_fibonacci.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/c05/ex04/ft_fibonacci.c b/c05/ex04/ft_fibonacci.c
new file mode 100644
index 0000000..66ff9b1
--- /dev/null
+++ b/c05/ex04/ft_fibonacci.c
@@ -0,0 +1,22 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_fibonacci.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/06 19:34:02 by cacharle #+# #+# */
+/* Updated: 2019/07/06 19:37:37 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+int ft_fibonacci(int index)
+{
+ if (index < 0)
+ return (-1);
+ if (index == 0)
+ return (0);
+ if (index == 1 || index == 2)
+ return (1);
+ return ft_fibonacci(index - 1) + ft_fibonacci(index - 2);
+}