The easiest way to do such type of questions is to use for loop. But they haven't touched this topic yet. So why are they giving such kind of questions? Any hidden agenda behind this?