Answers for "Find the series of Fibonacci numbers using lambda function."

0

Find the series of Fibonacci numbers using lambda function.

from functools import reduce
 
fib_series = lambda n: reduce(lambda x, _: x+[x[-1]+x[-2]],
                                range(n-2), [0, 1])
 
print("Fibonacci series upto 2:")
print(fib_series(2))
print("\nFibonacci series upto 5:")
print(fib_series(5))
print("\nFibonacci series upto 6:")
print(fib_series(6))
print("\nFibonacci series upto 9:")
print(fib_series(9))
Posted by: Guest on September-25-2021

Code answers related to "Find the series of Fibonacci numbers using lambda function."

Browse Popular Code Answers by Language