Program to print Reverse Floyd's triangle Last Updated : 20 Feb, 2023 Comments Improve Suggest changes Like Article Like Report Floyd’s triangle is a triangle with first natural numbers. Task is to print reverse of Floyd’s triangle.Examples: Input : 4 Output : 10 9 8 7 6 5 4 3 2 1 Input : 5 Output : 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 C++ // CPP program to print reverse of // floyd's triangle #include <bits/stdc++.h> using namespace std; void printReverseFloyd(int n) { int curr_val = n * (n + 1) / 2; for (int i = n; i >= 1; i--) { for (int j = i; j >= 1; j--) { cout << setprecision(2); cout << curr_val-- << " "; } cout << endl; } } // Driver's Code int main() { int n = 7; printReverseFloyd(n); return 0; } // this article is contributed by manish kumar rai Java // Java program to print reverse of // floyd's triangle import java.io.*; class GFG { static void printReverseFloyd(int n) { int curr_val = n * (n + 1) / 2; for (int i = n; i >= 1; i--) { for (int j = i; j >= 1; j--) { System.out.printf("%2d ", curr_val--); } System.out.println(""); } } // Driver method public static void main(String[] args) { int n = 7; printReverseFloyd(n); } } // this article is contributed by manish kumar rai Python3 # Python3 program to print reverse of # floyd's triangle def printReverseFloyd(n): curr_val = int(n*(n + 1)/2) for i in range(n + 1, 1, -1): for j in range(i, 1, -1): print(curr_val, end =" ") curr_val -= 1 print("") # Driver code n = 7 printReverseFloyd(n) C# // C# program to print reverse // of floyd's triangle using System; using System.Globalization; class GFG { static void printReverseFloyd(int n) { int curr_val = n * (n + 1) / 2; for (int i = n; i >= 1; i--) { for (int j = i; j >= 1; j--) { Console.Write(curr_val-- + " "); } Console.WriteLine(""); } } // Driver Code public static void Main() { int n = 7; printReverseFloyd(n); } } // This code is contributed by Sam007 PHP <?php // PHP program to print reverse // of floyd's triangle function printReverseFloyd($n) { $curr_val = $n * ($n + 1) / 2; for ($i = $n; $i >= 1; $i--) { for ( $j = $i; $j >= 1; $j--) { echo $curr_val-- , " "; } echo " \n"; } } // Driver Code $n = 7; printReverseFloyd($n); // This code is contributed by ajit ?> JavaScript <script> // Javascript program to print reverse of // floyd's triangle function printReverseFloyd(n) { let curr_val = n * (n + 1) / 2; for (let i = n; i >= 1; i--) { for (let j = i; j >= 1; j--) { document.write(curr_val-- + " "); } document.write("<br/>"); } } // Driver Code let n = 7; printReverseFloyd(n); </script> Output: 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 Time complexity: O(n2) for given input n Auxiliary space: O(1) Comment More infoAdvertise with us Next Article Program to print Reverse Floyd's triangle M Manish_100 Follow Improve Article Tags : Misc DSA Basic Coding Problems Reverse pattern-printing +1 More Practice Tags : Miscpattern-printingReverse Similar Reads Program to print binary right angle triangle Binary right angle triangle consists of only 0's and 1's in alternate positions. Examples : Input : 4 Output : 0 1 0 0 1 0 1 0 1 0 Input : 3 Output : 0 1 0 0 1 0 C++ // C program to print binary right angle // triangle. #include <stdio.h> // function to print binary right angle // triangle voi 4 min read Recursive program to print triangular patterns We have discussed iterative pattern printing in previous post. Examples: Input : 7 Output : * * * * * * * * * * * * * * * * * * * * * * * * * * * * Algorithm:- step 1:- first think for the base condition i.e. number less than 0 step 2:-do the recursive calls till number less than 0 i.e:- printPartte 8 min read Floyd's triangle in PL/SQL Prerequisite - PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Floyd's triangle is a right-angled triangular array of 2 min read Program to print Sum Triangle for a given array Given a array, write a program to construct a triangle where last row contains elements of given array, every element of second last row contains sum of below two elements and so on. Example: Input: arr[] = {4, 7, 3, 6, 7};Output:8140 4121 19 2211 10 9 134 7 3 6 7 Input: {10, 40, 50}Output:14050 901 9 min read Program to print the pattern with two hollow Triangles Given a number n, the task is to write a program to draw the following pattern using '$'. $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ Approach: The above pattern is printed by breaking it into smaller patterns: The abo 15+ min read Like