/greenfly

Greenfly can reproduce asexually. After one week of life a lone female can produce eight offspring a day. Starting at the beginning of day 1 with a single mature female, how many greenfly could there be by the end of day 28? It may be assumed that: • There are no deaths • All offspring are females Note that at the end of day 1 there will be 9 greenfly (original + 8 offspring). At the end of day 7 there will be 57 greenfly (original + 8 × 7 offspring). At the end of day 8 there will be 129 greenfly (original + 8 × 8 offspring + 64 offspring from the daughters produced on day 1)

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

The greenfly problem

Greenfly can reproduce asexually. After one week of life a lone female can produce eight offspring a day. Starting at the beginning of day 1 with a single mature female, how many greenfly could there be by the end of day 28? It may be assumed that: • There are no deaths • All offspring are females Note that at the end of day 1 there will be 9 greenfly (original + 8 offspring). At the end of day 7 there will be 57 greenfly (original + 8 × 7 offspring). At the end of day 8 there will be 129 greenfly (original + 8 × 8 offspring + 64 offspring from the daughters produced on day 1)

This is the Java port of the code provided by @njkamau in python.