Perennial System interview question

coding problem based on loops