Skip to content
Related Articles

Related Articles

Improve Article

Enneadecagonal number

  • Last Updated : 20 Jul, 2021

Given a number n, the task is to find the nth Enneadecagonal number. 
An Enneadecagonal number is a nineteen-sided polygon in mathematics. It belongs to a class of figurative numbers. The number contains the number of dots and the dots are arranged in a pattern or series. An Enneadecagonal number is also known as nonadecagon. The dots have common points and all other dots are arranged in the successive layer.
 

Examples :  

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

In case you wish to attend live classes with experts, please refer DSA Live Classes for Working Professionals and Competitive Programming Live for Students.

Input : 4 
Output :106
Input :10 
Output :775 



Enneadecagonal number

Formula to find nth Enneadecagonal number :
 

\begin{math}  Ed_{n}=((17n^2)-15n)/2 \end{math}

 

C++




// C++ program to find
// nth Enneadecagonal number
#include <bits/stdc++.h>
using namespace std;
 
// Function to calculate
// Enneadecagonal number
int nthEnneadecagonal(long int n)
{
    // Formula for finding
    // nth Enneadecagonal number
    return (17 * n * n - 15 * n) / 2;
}
 
// Drivers code
int main()
{
    long int n = 6;
    cout << n << "th Enneadecagonal number :" << nthEnneadecagonal(n);
    return 0;
}

Java




// Java program to find
// nth Enneadecagonal number
import java.io.*;
 
class GFG {
 
    // Function to calculate
    // Enneadecagonal number
    static int nthEnneadecagonal(int n)
    {
         
        // Formula for finding
        // nth Enneadecagonal number
        return (17 * n * n - 15 * n) / 2;
    }
     
    // Driver Code
    public static void main (String[] args)
    {
         
        int n = 6;
        System.out.print(n + "th Enneadecagonal number :");
     
        System.out.println( nthEnneadecagonal(n));
    }
}
 
// This code is contributed by m_kit.

Python3




# Program to find nth
# Enneadecagonal number
 
def nthEnneadecagonal(n) :
     
    # Formula to calculate nth
    # Enneadecagonal number
    return (17 * n * n - 15 * n) // 2
 
# Driver Code
if __name__ == '__main__' :
         
    n = 6
    print(n,"th Enneadecagonal number :"
                , nthEnneadecagonal(n))
 
# This code is contributed  by Ajit

C#




// C# program to find
// nth Enneadecagonal number
using System;
 
class GFG
{
    // Function to calculate
    // Enneadecagonal number
    static int nthEnneadecagonal(int n)
    {
         
    // Formula for finding
    // nth Enneadecagonal number
    return (17 * n * n - 15 * n) / 2;
    }
     
    // Driver Code
    static public void Main ()
    {
    int n = 6;
    Console.Write(n + "th Enneadecagonal number :");
     
    Console.WriteLine( nthEnneadecagonal(n));
    }
}
 
// This code is contributed by aj_36

PHP




<?php
// PHP program to find
// nth Enneadecagonal number
 
// Function to calculate
// Enneadecagonal number
function nthEnneadecagonal($n)
{
    // Formula for finding
    // nth Enneadecagonal number
    return (17 * $n * $n -
            15 * $n) / 2;
}
 
// Driver Code
$n = 6;
echo $n , "th Enneadecagonal number :" ,
                  nthEnneadecagonal($n);
 
// This code is contributed by ajit
?>

Javascript




<script>
    // Javascript program to find nth Enneadecagonal number
     
    // Function to calculate
    // Enneadecagonal number
    function nthEnneadecagonal(n)
    {
           
        // Formula for finding
        // nth Enneadecagonal number
        return (17 * n * n - 15 * n) / 2;
    }
     
    let n = 6;
    document.write(n + "th Enneadecagonal number :");
 
    document.write( nthEnneadecagonal(n));
     
</script>

Output:  

6th Enneadecagonal number :261

Time Complexity: O(1)
Auxiliary Space: O(1)




My Personal Notes arrow_drop_up
Recommended Articles
Page :