Fibonacci Series (one liner code)

PHOTO EMBED

Wed Aug 10 2022 08:37:28 GMT+0000 (UTC)

Saved by @redpsych

from functools import reduce
fibSequence = lambda n: reduce(lambda x, _: x+[x[-1]+x[-2]], range(n-2), [0, 1])
print(fibSequence(10))
print(fibSequence(5))
print(fibSequence(6))
content_copyCOPY