From 77ffde450e92ffe6527c35ffc2383b17d4c04f68 Mon Sep 17 00:00:00 2001 From: braxtonhall Date: Sun, 23 Oct 2022 12:27:49 -0700 Subject: Rename directory to use GitHub ID --- entries/braxtonhall/homework/fib.cpp | 32 ++++++++++++++++++++++++++++++++ entries/braxtonhall/homework/fib.hpp | 4 ++++ 2 files changed, 36 insertions(+) create mode 100644 entries/braxtonhall/homework/fib.cpp create mode 100644 entries/braxtonhall/homework/fib.hpp (limited to 'entries/braxtonhall/homework') diff --git a/entries/braxtonhall/homework/fib.cpp b/entries/braxtonhall/homework/fib.cpp new file mode 100644 index 0000000..900c9d0 --- /dev/null +++ b/entries/braxtonhall/homework/fib.cpp @@ -0,0 +1,32 @@ +#include "fib.hpp" + +#include +#include +#include + +using namespace std; + +int Fibonacci::fib(const int n) const +{ + // cout << "start" << endl; + if (n < 0) { + // HOW?? + cout << "wtfff got ( " << n << " )" << endl; + // https://stackoverflow.com/questions/8480640/how-to-throw-a-c-exception + throw invalid_argument("received negative value"); + } else if (n == 0) { + // cout << "********************* LINE 12" << endl; + // https://stackoverflow.com/questions/1451170/in-the-fibonacci-sequence-is-fib0-0-or-1 + return 0; //1; ?????? + } else if (n == 1) { + // cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!! LINE 15" << endl; + return 1; + } else { + // cout << "GOT TO LINE 19" << endl; + // cout << "got here" << endl; + // int retVal = fib(n - 1) + fib(n - 2); + return fib(n - 1) + fib(n - 2); + // // cout << "here" << endl; + // cout << "returning: (" << retVal << " )" << endl; + } +} diff --git a/entries/braxtonhall/homework/fib.hpp b/entries/braxtonhall/homework/fib.hpp new file mode 100644 index 0000000..a7bbd30 --- /dev/null +++ b/entries/braxtonhall/homework/fib.hpp @@ -0,0 +1,4 @@ +class Fibonacci +{ + int fib(const int n) const; +}; -- cgit v1.2.3-70-g09d2