# Icosagonal number

Given a number n, the task is to find the nth Icosagonal number.
An Icosagonal number is the 20-gon is a twenty-sided polygon. The number derived from the figurative class. There are different pattern series number in this number. The dots are countable, arrange in a specific way of position and create a diagram. All the dots have a common dots points, all others dots are connected to this points and except this common point the dots connected to their i-th dots with their respective successive layer.
Examples :

Input : 3
Output :57
Input :8
Output :512

Formula for nth icosagonal number:

## C++

 // C++ program to find // nth Icosagonal number #include  using namespace std;   // Function to calculate Icosagonal number int icosagonal_poly(long int n) {     // Formula for finding     // nth Icosagonal number     return (18 * n * n - 16 * n) / 2; }   // Drivers code int main() {     long int n = 7;     cout << n << "th Icosagonal number :"                << icosagonal_poly(n);       return 0; }

## C

 // C program to find // nth Icosagonal number #include    // Function to calculate Icosagonal number int icosagonal_poly(long int n) {         // Formula for finding     // nth Icosagonal number     return (18 * n * n - 16 * n) / 2; }   // Drivers code int main() {     long int n = 7;     printf("%ldth Icosagonal number : %d",n,icosagonal_poly(n));       return 0; }

## Java

 // Java program to find // nth Icosagonal number   import java.io.*;   class GFG {       // Function to calculate Icosagonal number   static int icosagonal_poly(int n) {     // Formula for finding     // nth Icosagonal number     return (18 * n * n - 16 * n) / 2; }   // Drivers code           public static void main (String[] args) {          int n = 7;           System.out.print (n + "th Icosagonal number :");     System.out.println(icosagonal_poly(n));     } } // This code is contributed by aj_36

## Python 3

 # Python 3 program to find  # nth Icosagonal number   # Function to calculate # Icosagonal number def icosagonal_poly(n) :           # Formula for finding     # nth Icosagonal number     return (18 * n * n -             16 * n) // 2   # Driver Code if __name__ == '__main__' :     n = 7     print(n,"th Icosagonal number : ",                     icosagonal_poly(n))   # This code is contributed m_kit

## C#

 // C# program to find // nth Icosagonal number using System;   class GFG {   // Function to calculate // Icosagonal number static int icosagonal_poly(int n) {     // Formula for finding     // nth Icosagonal number     return (18 * n * n -              16 * n) / 2; }   // Driver code static public void Main () {       int n = 7;   Console.Write(n + "th Icosagonal " +                         "number :"); Console.WriteLine(icosagonal_poly(n)); } }   // This code is contributed by ajit

## PHP

 

## Javascript

 

Output :

7th Icosagonal number :385

Time Complexity: O(1)
Auxiliary Space: O(1)
Reference: https://en.wikipedia.org/wiki/Polygonal_number

Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!