aboutsummaryrefslogtreecommitdiff
path: root/entries/Tarcisio-Teixeira/fib.py
diff options
context:
space:
mode:
authorTarcisio-Teixeira2022-10-24 00:02:58 +0000
committerGitHub2022-10-24 00:02:58 +0000
commitd0513187789505955e41441973c63848ec247cbc (patch)
tree68cf0cade30f790038cf66713ebbbb2f84380e1f /entries/Tarcisio-Teixeira/fib.py
parent97d0bca7470bef068b5852a94c5e51c103b0400c (diff)
Update fib.py
Diffstat (limited to 'entries/Tarcisio-Teixeira/fib.py')
-rw-r--r--entries/Tarcisio-Teixeira/fib.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/entries/Tarcisio-Teixeira/fib.py b/entries/Tarcisio-Teixeira/fib.py
index 1246517..a73cdd2 100644
--- a/entries/Tarcisio-Teixeira/fib.py
+++ b/entries/Tarcisio-Teixeira/fib.py
@@ -2,4 +2,4 @@ def fib(n,arr={},v =-1):
if v>=0:
arr[n]=v
return v
- return arr[n] if n in arr.keys() else fib(n, arr, (3*n*n*n - 9*n*n+13*n)//6 if n <= 3 else fib(n//2-1,arr)*fib(n-n//2,arr) + fib(n//2,arr)*fib(n-n//2+1,arr))
+ return arr[n] if n in arr.keys() else fib(n, arr, (2*n*n*n - 9*n*n+13*n)//6 if n <= 3 else fib(n//2-1,arr)*fib(n-n//2,arr) + fib(n//2,arr)*fib(n-n//2+1,arr))