The following numbers form the concentric hexagonal sequence :
0, 1, 6, 13, 24, 37, 54, 73, 96, 121, 150 ……
The number sequence forms a pattern with concentric hexagons, and the numbers denote the number of points required after the n-th stage of the pattern.
Input : N = 3
Output : 13
Input : N = 4
Output : 24
The above series can be referred from Concentric Hexagonal Numbers.
Nth term of the series is 3*n2/2
Below is the implementation of the above approach :
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.