aboutsummaryrefslogtreecommitdiff
path: root/entries
diff options
context:
space:
mode:
authorBraxton Hall2022-12-09 19:29:18 +0000
committerGitHub2022-12-09 19:29:18 +0000
commit1eec7f557b37ff0ff814e95c13163a2dc397b467 (patch)
tree24297d78c17e2b6f136a62da21c739ec3af73c43 /entries
parentea21a343d407bda33e5b4dfbeb711a975a5aa4e6 (diff)
parent401c8df449eecce4df1ba459d163d20b2caf6910 (diff)
Merge pull request #92 from ardier/main
Ardi's entry in Python
Diffstat (limited to 'entries')
-rw-r--r--entries/ardier/python/main.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/entries/ardier/python/main.py b/entries/ardier/python/main.py
new file mode 100644
index 0000000..c35ad6a
--- /dev/null
+++ b/entries/ardier/python/main.py
@@ -0,0 +1,11 @@
+def fib_helper(entry: int) -> int:
+ return 1 if entry in {1,2} else fib_helper(entry-1) + fib_helper(entry-2)
+
+
+def fib(entry: int) -> int:
+ return 0 if entry == 0 else(-fib_helper(abs(entry)) if (entry < 0 and (entry %2 == 0)) else fib_helper(abs(entry)))
+
+
+if __name__ == "__main__":
+ for i in range(-20, 20):
+ print(f'The fib value for {i} is {fib(i)}') \ No newline at end of file