Rabbits Rule

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

Answer:

Month 6 starts out with five total rabbits three of which are mature. During the month the mature rabbits gives birth to three babies, so there are eight rabbits at the end of the month.

Rabbits Rule

The updated chart shows the situation.

N12345 678910
Rabbits11235 8    

Here is what we have been doing:

rabbits At End Of Month( N ) = rabbits At End Of Month( N-1 ) 
                                             + 
                               rabbits Born During Month( N )

rabbits At End Of Month( N ) = rabbits At End Of Month( N-1 ) 
                                             + 
                               mature Rabbits During Month( N )

rabbits At End Of Month( N ) = rabbits At End Of Month( N-1 ) 
                                             + 
                               rabbits At End Of Month( N-2 )

Once you have this rule, to calculate the number of rabbits at the end of a month just add up the numbers for the previous two months.

QUESTION 14:

What is the value for the end of month 7?