Java Program to Display Floyd’s Triangle Last Updated : 05 Sep, 2022 Comments Improve Suggest changes Like Article Like Report Floyd’s triangle is a triangle with first natural numbers. It is the right arrangement of the numbers/values or patterns. Basically, it is a left to right arrangement of natural numbers in a right-angled triangle Illustration: Suppose if no of rows to be displayed is 5 then the desired output should display 5 rows as: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15Algorithm: Initialization of variablesCreate variables in memory holding rows and columns.Create and initialize variable holding patterns or values to be displayed.Traversing over rows and columns using nested for loops.Outer loop for rows.Inner loop for columns in the current row.Dealing with variable holding dynamic values as per execution as initialized outside nested loops.If values are to be displayed, increment this variable inside the loop for rows and outside loop for columns.If patterns are to be displayed, assign the character outside loop while creation and no alternation of holder value in any of loops.Implementation: Floyd’s Triangle Example Java // Java program to display Floyd's triangle // Importing Java libraries import java.util.*; // Main class class GFG { // Main driver method public static void main(String[] args) { // No of rows to be printed int n = 5; // Creating and initializing variable for // rows, columns and display value int i, j, k = 1; // Nested iterating for 2D matrix // Outer loop for rows for (i = 1; i <= n; i++) { // Inner loop for columns for (j = 1; j <= i; j++) { // Printing value to be displayed System.out.print(k + " "); // Incremeting value displayed k++; } // Print elements of next row System.out.println(); } } } Output1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Time Complexity: O(n2) for given n Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article Java Program to Display Floyd’s Triangle A abhijithoyur Follow Improve Article Tags : Java Technical Scripter Java Programs Technical Scripter 2020 Practice Tags : Java Similar Reads Java Program to Find the Area of a Triangle A triangle is a polygon. It has three edges and three vertices and each vertex from an angle. It is a closed 2-dimensional shape. In this article, we will learn how to find the area of the triangle.There can be two possibilities while calculating the area of the triangle as per casesUsing the height 3 min read Java Program to Apply Delaunay Triangulation Algorithm Computational geometry to triangulate a set of points in a plane or in higher dimensions is not an easy task but we can perform this using Delaunay Triangulation Algorithm. Let us apply Delaunay Triangulation Algorithm in this article. What is Delaunay Triangulation Algorithm? Delaunay triangulation 8 min read Java Program to Print Pascal's Triangle Pascal's triangle is a pattern of the triangle which is based on nCr.below is the pictorial representation of Pascal's triangle.Example:Input : N = 5Output: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1Approach #1: nCr formula: n ! / ( n - r ) ! r ! After using nCr formula, the pictorial representation becomes: 0C0 3 min read Java Program to Print Downward Triangle Star Pattern Downward triangle star pattern means we want to print a triangle that is downward facing means base is upwards and by default, orientation is leftwards so the desired triangle to be printed should look like * * * * * * * * * * Example Java // Java Program to Print Lower Star Triangle Pattern // Main 2 min read Java Program to Print Star Pascalâs Triangle Pascalâs triangle is a triangular array of the binomial coefficients. Write a function that takes an integer value n as input and prints the first n lines of Pascalâs triangle. Following are the first 6 rows of Pascalâs Triangle.In this article, we will look into the process of printing Pascal's tri 4 min read Like