Softwire interview question

Remaking a nested for loop ignoring useless iterations