{"id":22662,"date":"2021-09-27T08:36:54","date_gmt":"2021-09-27T03:06:54","guid":{"rendered":"https:\/\/python-programs.com\/?p=22662"},"modified":"2021-11-22T18:35:38","modified_gmt":"2021-11-22T13:05:38","slug":"python-program-to-find-nth-pentagonal-number","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-nth-pentagonal-number\/","title":{"rendered":"Python Program to Find N\u2019th Pentagonal Number"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Check if Three Points are Collinear<\/a>
\nGiven a number N the task is to find the Nth Pentagonal Number in Python.<\/p>\n

Nth Pentagonal Number:<\/strong><\/p>\n

n is the nth pentagonal number. When the pentagons are overlapped so that they share one vertex, Pn is the number of different dots in a pattern of dots consisting of the outlines of regular pentagons with sides up to n dots.<\/p>\n

A polygonal number (triangular number, square number, and so on) is a number that is represented as dots or pebbles ordered in the shape of a regular polygon. The first few pentagonal numbers are as follows: 1, 5, 12, and so on.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 4<\/pre>\n

Output:<\/strong><\/p>\n

The { 4 } pentagonal number =  22<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 6<\/pre>\n

Output:<\/strong><\/p>\n

The { 6 } pentagonal number = 51<\/pre>\n

Program to Find N\u2019th Pentagonal Number in Python<\/h2>\n

Below are the ways to find the Nth Pentagonal Number in Python:<\/p>\n