I have forgotten
my Password

COST (GBP)
1.40
0.00
0

# Pentagonal Number

Calculates the pentagonal number of the given order.
Controller: CodeCogs

C++
Excel

## Pentagonal Number

 intpentagonal_number( int n )[inline]
This function computes the pentagonal number of order n. The pentagonal number $\inline&space;&space;P(n)$ counts the number of dots in a figure of $\inline&space;&space;n$ nested pentagons. The pentagonal numbers are defined for both positive and negative orders.

## Example:

```#include <codecogs/maths/combinatorics/sequences/pentagonal_number.h>
#include <iostream>
int main()
{
std::cout << "Pentagonal numbers for 0 <= n < 10" << std::endl;
for (int i = 0; i < 10; i++)
std::cout << i << "  " << Maths::Combinatorics::Sequences::pentagonal_number(i) << std::endl;
return 0;
}```

## Output:

```Pentagonal numbers for 0 <= n < 10
0  0
1  1
2  5
3  12
4  22
5  35
6  51
7  70
8  92
9  117```

## References:

SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.html

### Parameters

 n the desired order

### Returns

the value of the pentagonal number of order n

### Authors

Lucian Bentea (August 2005)
##### Source Code

Source code is available when you buy a Commercial licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.