If it really is that simple, read up on -
while, for, do, loop, break and continue.
The answer should be hiding in there somewhere.
And you’ll learn something new as well.
Seriously though, programming is not the ability to see how many bandages will stick on top of each other, it requires planning, understanding and review - on top of coding, testing and debugging.
If “planning, understanding and review” are a secret society,the world is doomed ! (I’m not doubting it)