Java program to print inverted floyd’s triangle of numbers
Written by
Program that prints an Inverted Floyd Triangle in Java.
Source Code:
/* Program to print Inverted Floyd Triangle*/
import java.util.*;
class InvNumFloyd
{
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=0;
System.out.println("Inverted Floyd Triangle: \n");
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
x++;
}
for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++)
{
System.out.print(x+" ");
x--;
}
System.out.println();
}
}
}
Output:
Enter Size Limit: 5
Inverted Floyd Triangle:
15 14 13 12 11
10 9 8 7
6 5 4
3 2
1