import java.io.*; public class NestedLoop { public static void main(String [] arg) throws IOException{ int num_input; int i,j; BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Please input the number of lines:"); num_input = Integer.parseInt(input.readLine()); i = 1; while(i <= num_input) { j = 1; while(j <= i) { System.out.print(""+j+" "); j++; } // The inner loop prints out one line, // that is to print out 1 to i. System.out.println(); // After the inner loop finishes // printting one line, // we should change to a new line. i++; } } }