Floyd triangle in Java(of numbers)
Written by
Program that prints Floyd Triangle in Java.
Source Code:
/* Program to print Floyd Triangle with Numbers*/
import java.util.*;
class NumFloyd
{
public static void main()
{
Scanner inp=new Scanner(System.in);
System.out.print("\n Enter Size Limit: ");
int n=inp.nextInt();
int i,j,x=1;
System.out.println("Floyd Triangle: \n");
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(x+" ");
x++;
}
System.out.println();
}
}
}
Output:
Enter Size Limit: 5
Floyd Triangle:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15