Created
April 30, 2020 21:09
-
-
Save amandaroos/e4fbf5752ec794aeb96da405f0b215b8 to your computer and use it in GitHub Desktop.
Non-recursive way of solving Fibonacci rabbits: http://rosalind.info/problems/fib/
This file contains hidden or 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
#n is generations, m is pairs of rabbits born per litter | |
#b is pairs of baby bunnies, B is pairs of adult bunnies | |
def get_rabbits(n, m): | |
b, B = 1, 0 | |
for i in range(1, n): | |
b, B = B * m, B + b | |
return B + b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment