mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-02 06:46:18 -04:00
👾
This commit is contained in:
parent
1d44d182e2
commit
a85ed914d3
320 changed files with 0 additions and 0 deletions
16
math/fibonacci.py
Normal file
16
math/fibonacci.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# author: bt3gl
|
||||
|
||||
def fibonacci(n):
|
||||
""" Calculate the nth Fibonacci number """
|
||||
if n == 0 or n == 1:
|
||||
return n
|
||||
return fibonacci(n - 1) + fibonacci(n - 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
print('Testing fibonacci')
|
||||
n = 10
|
||||
print(f'Fibonacci of {n}: {fibonacci(n)}')
|
Loading…
Add table
Add a link
Reference in a new issue