From e34b5639937644d13cd9971ec82dc25f1dc80773 Mon Sep 17 00:00:00 2001 From: Atharva Date: Tue, 3 Oct 2023 01:53:02 +0530 Subject: [PATCH] Updated task-5 --- Project/Python Progs/Dynamic programming.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Project/Python Progs/Dynamic programming.py diff --git a/Project/Python Progs/Dynamic programming.py b/Project/Python Progs/Dynamic programming.py new file mode 100644 index 00000000..48ab8310 --- /dev/null +++ b/Project/Python Progs/Dynamic programming.py @@ -0,0 +1,11 @@ +def fibonacci_tabulation(n): + if n <= 1: + return n + fib = [0] * (n+1) + fib[1] = 1 + for i in range(2, n+1): + fib[i] = fib[i-1] + fib[i-2] + return fib[n] + +# Example usage: +print(fibonacci_tabulation(10)) # Output: 55