diff options
| author | Asahel <[email protected]> | 2024-02-01 20:57:20 -0800 |
|---|---|---|
| committer | Asahel <[email protected]> | 2024-02-01 20:57:20 -0800 |
| commit | 98942d6c6450b7613b54025b84e456078b3edaa6 (patch) | |
| tree | 3f2d096afa11aa4a9bc82b4ada723dfe5456ec6c /Homework3/recursive.cpp | |
| parent | Added recursive.cpp and recursive.h (diff) | |
| download | homework-3-asahellt-98942d6c6450b7613b54025b84e456078b3edaa6.tar.xz homework-3-asahellt-98942d6c6450b7613b54025b84e456078b3edaa6.zip | |
Implemented Fib function
Diffstat (limited to 'Homework3/recursive.cpp')
| -rw-r--r-- | Homework3/recursive.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Homework3/recursive.cpp b/Homework3/recursive.cpp index 281ccd9..286a774 100644 --- a/Homework3/recursive.cpp +++ b/Homework3/recursive.cpp @@ -7,4 +7,16 @@ long factorial(int a) if (a == 1 || a == 0) return 1; return a * factorial(a - 1); + +} + +size_t fibonacci(int a) { + + if (a == 1 || a == 0) { + return a; + } + else { + return (fibonacci(a - 1) + fibonacci(a - 2)); + } + }
\ No newline at end of file |