floyd 27s triangle number pattern using while loop in java

Solutions on MaxInterview for floyd 27s triangle number pattern using while loop in java by the best coders in the world

showing results for - "floyd 27s triangle number pattern using while loop in java"
Linda
13 Nov 2018
1// Floyd's triangle number pattern using while loop in java
2import java.util.Scanner;
3public class FloydTriangleWhileLoop
4{
5   public static void main(String[] args) 
6   {
7      Scanner sc = new Scanner(System.in);
8      System.out.println("Enter the number of rows of floyd's triangle you want to print: ");
9      int rows = sc.nextInt();
10      int number = 1;
11      System.out.println("Floyd triangle in java using while loop");
12      int a = 1;
13      int b = 1;
14      while(a <= rows)
15      {
16         b = 1;
17         while(b <= a)
18         {
19            System.out.println(number + " ");
20            number++;
21            b++;
22         }
23         System.out.println();
24         a++;
25      }
26      sc.close();
27   }
28}