Ensure the inner loop increments correctly with j++. Keep the condition j <= i in the inner loop. Avoid accidental modifications to loop control variables (i or j) inside the loops.