# Program to print Reverse Floyd’s triangle

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 ` `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

 `= 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  ` `?> `

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
```

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Improved By : Sam007, jit_t

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.