fibonacci series what Iam is missing ?
Gregory Ewing
greg.ewing at canterbury.ac.nz
Tue Mar 24 03:54:42 EDT 2015
Chris Angelico wrote:
> Commenting is like dieting. You can always start tomorrow.
I've been meaning to become a procrastinator, but
I think I'll start tomorrow.
In the meantime, since we seem to be having a
fibbing competition, here's my contribution, that
uses neither recursion nor (explicit) iteration:
from numpy import array, dot
a = array([[0,1],[1,1]])
b = array([0,1])
def fib(n):
return reduce(dot,[a]*n+[b])[1]
for i in range(10):
print(fib(i))
--
Greg
More information about the Python-list
mailing list