One mosquito is born at T=0 and after 2 seconds it makes a new mosquito, and another every second thereafter. All such mosquitoes have this same property and do not die. How many mosquitoes there are at T=8.5?
A friend told me the answer is 32 (which is probably wrong), but when I try it on paper I get 22 but I think it's wrong too since I don't think I get the pattern right.
I coded it in C++:
class mosq {
public:
int cnt;
mosq() {
cnt = 0;
}
};
int main() {
std::vector<mosq> swarm, temp;
swarm.insert(swarm.end(), mosq());
for (int i = 0; i <= 8; i++){
for (auto &x : swarm) {
x.cnt++;
if(x.cnt>2) {
temp.insert(temp.end(), mosq());
}
}
swarm.insert(swarm.end(), temp.begin(), temp.end());
temp.clear();
}
getchar();
}
The result is 19 and the sequence is: 0,0,1,1,1,2,3,4,6.
But I still can't solve it on my own on paper correctly, how do you see the pattern in this kind of questions?
if(x.cnt>2) {
->>=
$\endgroup$