Created
March 28, 2011 17:54
-
-
Save mjdominus/890925 to your computer and use it in GitHub Desktop.
fibonacci identity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
choose _ 0 = 1 | |
choose 0 _ = 0 | |
choose n k = choose (n-1) (k-1) * n `div` k | |
pow n 0 = 1 | |
pow n k = n * pow n (k-1) | |
fib n = theSum `div` pow2 | |
where theSum = sum [ (choose n (2*k+1)) * (pow 5 k) | | |
k <- [0 .. div (n-1) 2] ] | |
pow2 = pow 2 (n-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment