Skip to content

Commit 111c176

Browse files
committed
Finonacci
1 parent cf42a33 commit 111c176

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

DP/Fibo.ipynb

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,30 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 2,
66
"metadata": {},
7-
"outputs": [],
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"Fibonacci Number is 5702887\n"
13+
]
14+
}
15+
],
816
"source": [
917
"def fib(n, lookup): \n",
1018
" \n",
11-
" # Base case \n",
1219
" if n == 0 or n == 1 : \n",
1320
" lookup[n] = n \n",
14-
" \n",
15-
" # If the value is not calculated previously then calculate it \n",
1621
" if lookup[n] is None: \n",
1722
" lookup[n] = fib(n-1 , lookup) + fib(n-2 , lookup) \n",
1823
" \n",
19-
" # return the value corresponding to that value of n \n",
2024
" return lookup[n] \n",
21-
"# end of function \n",
22-
" \n",
23-
"# Driver program to test the above function \n",
2425
"def main(): \n",
2526
" n = 34 \n",
26-
" # Declaration of lookup table \n",
27-
" # Handles till n = 100 \n",
2827
" lookup = [None]*(101) \n",
29-
" print \"Fibonacci Number is \", fib(n, lookup) \n",
28+
" print(\"Fibonacci Number is \", fib(n, lookup))\n",
3029
" \n",
3130
"if __name__==\"__main__\": \n",
3231
" main() "

0 commit comments

Comments
 (0)