From 93fed5991e90f44a40a4793dd001f8b29616720a Mon Sep 17 00:00:00 2001 From: mrshnra Date: Sun, 11 Oct 2015 11:47:00 -0400 Subject: [PATCH 1/4] Update fib.py --- fib.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/fib.py b/fib.py index 939bdbf..b3f5548 100644 --- a/fib.py +++ b/fib.py @@ -4,7 +4,13 @@ def fib_loop(n): It uses for loop to calculate it. ''' - + fib = [1,1] + + for i in range(n-2) + x= fib[i]+fib[i-1] + fib.append(x) + + return fib[n-1] def fib_recursion(n): ''' @@ -12,7 +18,15 @@ def fib_recursion(n): It uses for loop to calculate it. ''' - + fib1=1 + fib2=1 + + for i in range(n-2): + fib3 = fib2 + fib1 + fib1 = fib2 + fib2 = fib3 + + return fib3 print(fib_loop(8)) print(fib_recursion(13)) From dbbe8420621d15f5502b2dc3c862d93fdb253bb7 Mon Sep 17 00:00:00 2001 From: mrshnra Date: Sun, 11 Oct 2015 11:48:18 -0400 Subject: [PATCH 2/4] Update fib.py --- fib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fib.py b/fib.py index b3f5548..7cb7b13 100644 --- a/fib.py +++ b/fib.py @@ -6,7 +6,7 @@ def fib_loop(n): ''' fib = [1,1] - for i in range(n-2) + for i in range(n-2): x= fib[i]+fib[i-1] fib.append(x) From 45e4c763c88d91eecf5650dc347e1f4d2264caf8 Mon Sep 17 00:00:00 2001 From: mrshnra Date: Sun, 11 Oct 2015 11:49:56 -0400 Subject: [PATCH 3/4] Update fib.py --- fib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fib.py b/fib.py index 7cb7b13..e638720 100644 --- a/fib.py +++ b/fib.py @@ -7,7 +7,7 @@ def fib_loop(n): fib = [1,1] for i in range(n-2): - x= fib[i]+fib[i-1] + x= fib[i+1]+fib[i] fib.append(x) return fib[n-1] From cc92c8814186bcd13085c290a0790279a1f7a4d6 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 17 Oct 2015 16:19:22 -0400 Subject: [PATCH 4/4] I added a line --- fib.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fib.py b/fib.py index e638720..a01361c 100644 --- a/fib.py +++ b/fib.py @@ -30,3 +30,5 @@ def fib_recursion(n): print(fib_loop(8)) print(fib_recursion(13)) + +Hello World