Ok, so in the CB you have expressed now that you want to do it using a for loop, and we also managed to ascertain that this is homework.
I don't mind helping with homework, but the first step has to be the step YOU take. You show us the code you've written so far to get started on the task, and then ask us to help with the step that you are stumbling on. Then we give a thoughtful answer. That's sort of how the learning process works.