From 71878d619815d2d0759dafc33f83ff45dec10843 Mon Sep 17 00:00:00 2001 From: hp Date: Tue, 13 Oct 2015 12:06:05 -0400 Subject: [PATCH] first try --- fib.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fib.py b/fib.py index 939bdbf..b20cd67 100644 --- a/fib.py +++ b/fib.py @@ -16,3 +16,23 @@ def fib_recursion(n): print(fib_loop(8)) print(fib_recursion(13)) + + + + +from math import * + +def fibonacci(n): + sqrt_5 = sqrt(5); + p = (1 + sqrt_5) / 2; + q = 1/p; + return int( (p**n + q**n) / sqrt_5 + 0.5 ) + +for i in range(1,31): + fibonacci(i), +fibonacci(10) + + + + +