If you need nested loops because it's a homework assignment, then you need to be specific about what is allowed and what is not allowed. A specific set of conditions might make it necessary to write a nested loop, but I an not going to waste my time trying to figure them out.