Table of Contents
floyd’s triangle number pattern using for loop in Java
In this article, we will discuss Floyd’s triangle number pattern using for loop in Java
We can display many types of the rectangle, square shapes, many types of tables, pyramid shapes and Floyd’s triangle shapes using java.
In this post, we are going to how to display triangle number pattern using for loop in Java language
We will use for loop, in java for this purpose
How to print this floyd’s triangle using numaric numbers?
1
12
123
1234
12345
123456
1234567
12345678
123456789
12345678910
Program 2
class patternn{
public static void main(String args[]){
for(int i=1; i<=10; i++)
{
for(int j=1; j<=i; j++){
System.out.print(j);
}
System.out.println();
}
}
}
Wen the above code is executed, it produces the folowing result
Program 3
- How to print inverted floyd’s triangle using numaric numbers?
12345678910
123456789
12345678
1234567
123456
12345
1234
123
12
1
class forcondition1{ public static void main(String args[]){ int y=10; for(int row=10; row>=1; row--){ for(int coloum=1; coloum<=y; coloum++) { System.out.print(coloum); } System.out.println(); y=y-1; } } }
When the above code is compiled and executed, it produces the following result:
- How to print floyd’s triangle using numaric numbers?
10
99
888
7777
66666
555555
4444444
33333333
222222222
1111111111
program 4
class forcondition3{ public static void main(String args[]){ int y=10; for(int row=10; row>=1; row--){ for(int coloum=10; coloum>=y; coloum--) { System.out.print(row); } System.out.println(); y=y-1; } } }
When the above code is compiled and executed, it produces the following result:
this is another inverted Floyd’s triangle using numeric numbers?
- How to print inverted Floyd’s triangle using numeric numbers?
1
12
123
1234
12345
123456
123456
12345
1234
123
12
1
Program 5
public class PrintingFourPatternUsingLoops { public static void main(String[] args) { for (int i = 1; i < 7; i++) { for (int j = 1; j < i + 1; j++) { System.out.print(j); } System.out.println(); } System.out.println(); for(int k = 8; k > 1; k--) { for(int l = 1; l < k - 1; l++){ System.out.print(l); } System.out.println(); } } }
When the above code is compiled and executed, it produces the following result:
- How to print Floyd’s triangle using numeric numbers?
1
212
32123
4321234
543212345
Program 6
public class Demo8 { public static void main(String[] args) { for(int i=1;i<=5;i++) { for(int j=i;j>=1;j--) { System.out.print(j); } for (int k=2;k<=i;k++) { System.out.print(k); } System.out.println(); } } }
When the above code is compiled and executed, it produces the following result: