Created
May 4, 2014 01:17
-
-
Save codeguru42/a2996142c36ccdc04dbc to your computer and use it in GitHub Desktop.
FIBD
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
fibd n m = sum $ fibd' !! (n-1) | |
where fibd' = [[fibd'' i j | i <- [0..m]] | j <- [0..n]] | |
-- `fibd'' i j` is the number of rabbits which are `i` months old after `j` months since the first generation | |
fibd'' 0 0 = 1 | |
fibd'' _ 0 = 0 | |
fibd'' 0 j = sum . tail $ fibd' !! (j-1) | |
fibd'' i j = fibd' !! (j-1) !! (i-1) | |
main = do | |
print $ fibd n m | |
where n = 6 | |
m = 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment