Rabbit Pairs
You start with one newborn pair of rabbits. A pair needs one full month to mature; from its second month of life on, every month it produces a litter of litter new pairs. Rabbits never die. Return the number of pairs alive in month months, where month 1 is the month you start with the newborn pair.
Example 1
months 5
litter 1
returns 5
With litter 1 this is Fibonacci: 1, 1, 2, 3, 5.
Example 2
months 4
litter 3
returns 7
1, 1, 4, 7.
Constraints
1 <= months <= 121 <= litter <= 5
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Dynamic programming problems
- Ribbon for SaleEasy
- Three Step StairsEasy
- Tiling a Two by N StripEasy
- Token Orders at the TurnstileEasy
- Two-Lane RoadEasy
- Best Stretch SumMedium
- Cheapest DescentMedium
- Cheapest Pool PassesMedium