Rewrite the first exercise using a for loop instead of while