Given a number N, the task is to find Nth icosikaienneagonal number.
An icosikaienneagonal number is class of figurate number. It has 29 – sided polygon called icosikaienneagon. The N-th icosikaienneagonal number count’s the 29 number of dots and all others dots are surrounding with a common sharing corner and make a pattern. The first few icosikaienneagonal numbers are 1, 29, 84, 166 …
Examples :
Input : N = 2 Output : 29 Explanation : The second icosikaienneagonal number is 29. Input : N = 3 Output : 84
Approach :
The N-th icosikaienneagonal number is given by the formula:
Tn = (27n^2 - 25n)/2
Implementation :
C/C++
// C program for above approach
#include <stdio.h>
#include <stdlib.h>
// Finding the nth icosikaienneagonal Number
int icosikaienneagonalNum(int n)
{
return (27 * n * n - 25 * n) / 2;
}
// Driver program to test above function
int main()
{
int n = 3;
printf("3rd icosikaienneagonal Number is = %d",
icosikaienneagonalNum(n));
return 0;
}
Output :
3rd icosikaienneagonal Number is = 84