Iterative fibonacci with unittests from slash (#882)

* iterative and formula fibonacci methods

Added two ways to calculate the fibonacci sequence:  (1) iterative  (2) formula.  

I've also added a timer decorator so someone can see the difference in computation time between these two methods.  

Added two unittests using the slash framework.

* Update test_fibonacci.py

* remove inline comments per Contributing Guidelines

* Update sol5.py

* Create placeholder.py

* Update and rename maths/test_fibonacci.py to maths/tests/test_fibonacci.py

* Delete placeholder.py

* Create __init__.py

* Update test_fibonacci.py

* Rename Maths/lucasSeries.py to maths/lucasSeries.py

* Update and rename Project Euler/Problem 01/sol5.py to project_euler/problem_01/sol6.py
This commit is contained in:
StephenGemin
2019-06-08 08:25:34 -04:00
committed by John Law
parent 6e894ba3e8
commit 9b945cb2b4
6 changed files with 164 additions and 8 deletions

13
maths/lucasSeries.py Normal file
View File

@ -0,0 +1,13 @@
# Lucas Sequence Using Recursion
def recur_luc(n):
if n == 1:
return n
if n == 0:
return 2
return (recur_luc(n-1) + recur_luc(n-2))
limit = int(input("How many terms to include in Lucas series:"))
print("Lucas series:")
for i in range(limit):
print(recur_luc(i))