Open In App

Decakismyriagon Number

Last Updated : 06 Apr, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Given a number N, the task is to find Nth Decakismyriagon Number.
 

A Decakismyriagon Number is a class of figurate numbers. It has a 100000-sided polygon called Decakismyriagon. The N-th Decakismyriagon Number counts the 100000 number of dots and all other dots are surrounding with a common sharing corner and make a pattern. The first few Decakismyriagonol Numbers are 1, 100000, 299997, 599992, … 
 


Examples: 
 

Input: N = 2 
Output: 100000 
Explanation: 
The second Decakismyriagonol number is 100000. 
Input: N = 3 
Output: 299997 
 


 


Approach: The N-th Decakismyriagon Number is given by the formula: 
 

  • N-th term of S sided polygon = \frac{((S - 2)N^2 - (S - 4)N)}{2}
  • Therefore, the N-th term of 100000 sided polygon is given by: 
     

Tn =\frac{((100000 - 2)N^2 - (100000 - 4)N)}{2} =\frac{(99998N^2 - 99996N)}{2}
 


  •  


Below is the implementation of the above approach:
 

C/C++

 


 

C++

// C++ program for the above approach
#include <bits/stdc++.h>
using namespace std;
 
// Function to find the N-th
// Decakismyriagon Number
int DecakismyriagonNum(int N)
{
    return (99998 * N * N - 99996 * N)
        / 2;
}
 
// Driver Code
int main()
{
    // Given Number N
    int N = 3;
 
    // Function Call
    cout << DecakismyriagonNum(N);
 
    return 0;
}

                    

Java

// Java program for the above approach
class GFG{
 
// Function to find the N-th
// Decakismyriagon Number
static int DecakismyriagonNum(int N)
{
    return (99998 * N * N - 99996 * N) / 2;
}
 
// Driver code
public static void main(String[] args)
{
     
    // Given Number N
    int N = 3;
     
    // Function Call
    System.out.println(DecakismyriagonNum(N));
}
}
 
// This code is contributed by Pratima Pandey

                    

Python3

# Python3 program for the above approach
 
# Function to find the N-th
# Decakismyriagon Number
def DecakismyriagonNum(N):
 
    return (99998 * N * N - 99996 * N) // 2;
 
# Driver Code
 
# Given Number N
N = 3;
 
# Function Call
print(DecakismyriagonNum(N));
 
# This code is contributed by Code_Mech

                    

C#

// C# program for the above approach
using System;
class GFG{
 
// Function to find the N-th
// Decakismyriagon Number
static int DecakismyriagonNum(int N)
{
    return (99998 * N * N - 99996 * N) / 2;
}
 
// Driver code
public static void Main()
{
     
    // Given Number N
    int N = 3;
     
    // Function Call
    Console.Write(DecakismyriagonNum(N));
}
}
 
// This code is contributed by Code_Mech

                    

Javascript

<script>
 
// JavaScript program for the above approach
 
// Function to find the N-th
// Decakismyriagon Number
function DecakismyriagonNum(N) {
    return (99998 * N * N - 99996 * N) / 2;
}
 
// Driver Code
 
// Given Number N
let N = 3;
 
// Function Call
console.log(DecakismyriagonNum(N));
 
// This code is contributed by blalverma92
</script>

                    

Output: 
299997

 

Time Complexity: O(1)
 



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads