So I came across this formula of Fibonacci numbers as a binomial sum [1] [2]
$$ F_n = \sum_{k \mathop = 0}^{\lfloor {\frac {n - 1} 2} \rfloor} \dbinom {n - k - 1} k $$
I'm not really sure that this formula actually valid, I've computed some of the first terms and they don't look very much like Fibonacci numbers to me.
Maybe the identity is wrong, but several places have it stated in the same way. Does anyone know more about this identity? Thanks
#!/usr/bin/python3
from math import factorial, floor
def c(n,k):
return factorial(n)/(factorial(k)*factorial(n-k))
def f(n):
s=0
for k in range(floor((n-1)/2)):
s += int(c(n-k-1,k))
return s
for n in range(1,6):
# computing F(n)
print(f(n))
And the output is
0
0
1
1
4
[1] https://proofwiki.org/wiki/Fibonacci_Number_as_Sum_of_Binomial_Coefficients
//instead of/obviates the need forfloor,int. If it's 2 (which will be deprecated in January 2020),/does the same job as//. – J.G. Aug 25 '19 at 21:29