This second example is more efficient in terms of coding and maintainability, since it avoids writing the same statement multiple times and is easier to adjust the number of iterations.
In general, the use of a loop makes the code more readable and easier to maintain, allowing the programmer to perform repetitive actions with less code and in a more efficient way.