Nth s-gonal number P s n s - 2n n-12 n If we put s 5 we get nth Pentagonal number P n 3n n-12 n. The first few pentagonal numbers are. Another way to think about this formula is that 24P1 must be a perfect square and that its square root must be equivalent to 5 mod 6.
The first few pentagonal numbers are.
1 5 12 etc. Implementation of the method is given below. Given a number P calculate. If s is the number of sides in a polygon the formula for the nth s-gonal number P s n is.