You are given a number n, the task is to find the nth Decagonal number. A decagonal number is a figurate number that extends the concept of triangular and square numbers to the decagon (a ten-sided polygon). The nth decagonal numbers counts the number of dots in a pattern of n nested decagons, all sharing a common corner, where the ith decagon in the pattern has sides made of i dots spaced one unit apart from each other.
Input : n = 3 Output : 27 Input : n = 7 Output : 175
The n-th decagonal number is given by the formula
(4n 2 – 3n).
10th decagonal number : 370
Attention reader! Don’t stop learning now. Get hold of all the important mathematical concepts for competitive programming with the Essential Maths for CP Course at a student-friendly price. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.