Floyd's triangle number pattern using while loop in java
// Floyd's triangle number pattern using while loop in java
import java.util.Scanner;
public class FloydTriangleWhileLoop
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of rows of floyd's triangle you want to print: ");
int rows = sc.nextInt();
int number = 1;
System.out.println("Floyd triangle in java using while loop");
int a = 1;
int b = 1;
while(a <= rows)
{
b = 1;
while(b <= a)
{
System.out.println(number + " ");
number++;
b++;
}
System.out.println();
a++;
}
sc.close();
}
}