Merge pull request #38 from scraggard/master

[FEATURE] added fibonacci
This commit is contained in:
Angelos Chalaris
2019-08-19 13:42:15 +03:00
committed by GitHub
4 changed files with 48 additions and 2 deletions

View File

@ -0,0 +1,18 @@
### fibonacci_until_num
Returns the n-th term in a Fibonnaci sequence that starts with 1
A term in a Fibonnaci sequence is the sum of the two previous terms.
This function recursively calls the function to find the n-th term.
``` python
def fibonacci_until_num(n):
if n < 3:
return 1
return fibonacci_until_num(n - 2) + fibonacci_until_num(n - 1)
```
``` python
fibonnaci_until_num(5) # 5
fibonnaci_until_num(15) # 610
```