# Rectangular (or Pronic) Numbers

The numbers that can be arranged to form a rectangle are called Rectangular Numbers (also known as Pronic numbers). The first few rectangular numbers are:

0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420, 462 . . . . . .

Given a number n, find n-th rectangular number.

Examples:

Input : 1 Output : 2 Input : 4 Output : 20 Input : 5 Output : 30

The number 2 is a rectangular number because it is 1 row by 2 columns. The number 6 is a rectangular number because it is 2 rows by 3 columns, and the number 12 is a rectangular number because it is 3 rows by 4 columns.

If we observe these numbers carefully, we can notice that n-th rectangular number is **n(n+1)**.

## C++

`// CPP Program to find n-th rectangular number ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Returns n-th rectangular number ` `int` `findRectNum(` `int` `n) ` `{ ` ` ` `return` `n * (n + 1); ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `n = 6; ` ` ` `cout << findRectNum(n); ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java Program to find n-th rectangular number ` `import` `java.io.*; ` ` ` `class` `GFG { ` ` ` ` ` `// Returns n-th rectangular number ` ` ` `static` `int` `findRectNum(` `int` `n) ` ` ` `{ ` ` ` `return` `n * (n + ` `1` `); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` `int` `n = ` `6` `; ` ` ` `System.out.println(findRectNum(n)); ` ` ` `} ` `} ` ` ` `// This code is contributed by vt_m. ` |

*chevron_right*

*filter_none*

## C#

`// C# Program to find n-th rectangular number ` ` ` `using` `System; ` ` ` `class` `GFG { ` ` ` ` ` `// Returns n-th rectangular number ` ` ` `static` `int` `findRectNum(` `int` `n) ` ` ` `{ ` ` ` `return` `n * (n + 1); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `Main() ` ` ` `{ ` ` ` `int` `n = 6; ` ` ` `Console.Write(findRectNum(n)); ` ` ` `} ` `} ` ` ` `// This code is contributed by vt_m. ` |

*chevron_right*

*filter_none*

## Python

`# Python3 Program to find n-th rectangular number ` ` ` `# Returns n-th rectangular number ` `def` `findRectNum(n): ` ` ` `return` `n` `*` `(n ` `+` `1` `) ` ` ` `# Driver code ` `n ` `=` `6` `print` `(findRectNum(n)) ` ` ` `# This code is contributed by Shreyanshi Arun. ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP Program to find n-th ` `// rectangular number ` ` ` `// Returns n-th rectangular ` `// number ` `function` `findRectNum(` `$n` `) ` `{ ` ` ` `return` `$n` `* (` `$n` `+ 1); ` `} ` ` ` ` ` `// Driver Code ` ` ` `$n` `= 6; ` ` ` `echo` `findRectNum(` `$n` `); ` ` ` `// This code is contributed by ajit ` `?> ` |

*chevron_right*

*filter_none*

Output:

42

Check if a given number is Pronic | Efficient Approach

This article is contributed by DANISH_RAZA . 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: **DSA Self Paced**. Become industry ready at a student-friendly price.

## Recommended Posts:

- Sum of the first N Pronic Numbers
- Check if a given number is Pronic
- Check if a given number is Pronic | Efficient Approach
- Height of Pyramid formed with given Rectangular Box
- Find the volume of rectangular right wedge
- Sum of lengths of all 12 edges of any rectangular parallelepiped
- Maximum of smallest possible area that can get with exactly k cut of given rectangular
- Largest square which can be formed using given rectangular blocks
- Minimum sprinklers required to water a rectangular park
- Minimum number of square tiles required to fill the rectangular floor
- Fill the missing numbers in the array of N natural numbers such that arr[i] not equal to i
- Check if a given pair of Numbers are Betrothed numbers or not
- Numbers less than N which are product of exactly two distinct prime numbers
- Print N lines of 4 numbers such that every pair among 4 numbers has a GCD K
- Count numbers which can be constructed using two numbers
- Maximum sum of distinct numbers such that LCM of these numbers is N
- Count numbers which are divisible by all the numbers from 2 to 10
- Number of ways to obtain each numbers in range [1, b+c] by adding any two numbers in range [a, b] and [b, c]
- Absolute difference between the Product of Non-Prime numbers and Prime numbers of an Array
- Absolute Difference between the Sum of Non-Prime numbers and Prime numbers of an Array