Java program to print floyd’s triangle

In this post, we will see how to print Floyd’s triangle in java.

Problem

You need to print Floyd’s triangle as below for n=5.

Floyd’s triangle
****************
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

Floyd’s triangle in java

Let’s create class "FloydTriangleMainExample.java" as below

When you run above program, you will get below output:

Enter the number of rows for floyd’s triangle:
6
Floyd’s triangle
****************
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21

That’s all about printing floyd’s cycle in java.

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *