FUNCTION
Pentagonal_Number
Calculates the pentagonal number of the given order.
Interface
#include <codecogs/maths/combinatorics/sequences/pentagonal_number.h>
using namespace Maths::Combinatorics::Sequences;
This function computes the pentagonal number of order n. The pentagonal number counts the number of dots in a figure of
nested pentagons. The pentagonal numbers are defined for both positive and negative orders.
Parameters
n
the desired order
Returns
the value of the pentagonal number of order n
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
Interactive Calculator
n
Result
Computing…
Set a range above first to export a graph.
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.