Help me to solve my technical test

I have a problem with technical tests. Can I know in your opinion what is wrong and what should I do in the program?

the test:
In captivity there are 6969 couples. Every 21 days the bird simultaneously incubates a new lovebird. But before giving birth, 11.1% of lovebirds die. Create a program to find out and calculate the number of couples after 441 days

I’ve tried like this

let loveBird = 6969;
let jmlhYangMati;
let waktu = 21;


for (let i = 1; i <= waktu; i++) {
    jmlhYangMati = loveBird * 0.111;
    loveBird -= jmlhYangMati;
}

console.log(Math.floor(loveBird));

Where to you account for the births? And beware that 6969 is the number of couples, not birds.

1 Like

Ah yes, I just realized, so maybe it’s because of a partner so I have to multiply it by two right?

But that’s the only thing, so what’s the logic and even the code like?

That would be a good first step, to write out the algorithm in plain English (or whatever language you prefer) before you even begin trying to code it. So don’t even think about how you would code this yet. If you were just using a pencil and paper, how would you figure this out?

2 Likes