It is necessary to determine whether a number is a Fibonacci element using lambda, True / False.
There is a code fib = lambda n, a=1, b=2: int(((a + 5**0.5)**n - (b - 5**0.5)**n) / (b**n * 5**0.5)) Which only displays the element.
It is the same here, but I am not sure that it is possible to unpack the type a, b = b, a + b in anonymous functions.
def fib(n): a, b = 0, 1 for __ in range(n): a, b = b, a + b if n == b: return True return False print(fib(144))