diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-11-13 19:00:06 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-11-13 19:00:06 +0100 |
commit | 13eab863735725f9a02cd4ae0b1c25725cc27569 (patch) | |
tree | 20be81c90e02f3a5dee54392435bb7baf8e7b571 /01-algorithmic_toolbox/01-intro/01-fibonacci | |
download | coursera-13eab863735725f9a02cd4ae0b1c25725cc27569.zip coursera-13eab863735725f9a02cd4ae0b1c25725cc27569.tar.gz |
Algorithms : add 01-algorithmic_toolbox 01-intro
Diffstat (limited to '01-algorithmic_toolbox/01-intro/01-fibonacci')
5 files changed, 20 insertions, 0 deletions
diff --git a/01-algorithmic_toolbox/01-intro/01-fibonacci/fibonacci.cpp b/01-algorithmic_toolbox/01-intro/01-fibonacci/fibonacci.cpp new file mode 100644 index 0000000..adc7404 --- /dev/null +++ b/01-algorithmic_toolbox/01-intro/01-fibonacci/fibonacci.cpp @@ -0,0 +1,16 @@ +#include <iostream> + +int calc_fib(int n) { + if (n <= 1) + return n; + + return calc_fib(n - 1) + calc_fib(n - 2); +} + +int main() { + int n = 0; + std::cin >> n; + + std::cout << calc_fib(n) << '\n'; + return 0; +} diff --git a/01-algorithmic_toolbox/01-intro/01-fibonacci/tests/01 b/01-algorithmic_toolbox/01-intro/01-fibonacci/tests/01 new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/01-algorithmic_toolbox/01-intro/01-fibonacci/tests/01 @@ -0,0 +1 @@ +3 diff --git a/01-algorithmic_toolbox/01-intro/01-fibonacci/tests/01.a b/01-algorithmic_toolbox/01-intro/01-fibonacci/tests/01.a new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/01-algorithmic_toolbox/01-intro/01-fibonacci/tests/01.a @@ -0,0 +1 @@ +2 diff --git a/01-algorithmic_toolbox/01-intro/01-fibonacci/tests/02 b/01-algorithmic_toolbox/01-intro/01-fibonacci/tests/02 new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/01-algorithmic_toolbox/01-intro/01-fibonacci/tests/02 @@ -0,0 +1 @@ +10 diff --git a/01-algorithmic_toolbox/01-intro/01-fibonacci/tests/02.a b/01-algorithmic_toolbox/01-intro/01-fibonacci/tests/02.a new file mode 100644 index 0000000..c3f407c --- /dev/null +++ b/01-algorithmic_toolbox/01-intro/01-fibonacci/tests/02.a @@ -0,0 +1 @@ +55 |