Decakismyriagon Number
Last Updated :
06 Apr, 2021
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 =
- Therefore, the N-th term of 100000 sided polygon is given by:
Below is the implementation of the above approach:
C/C++
C++
#include <bits/stdc++.h>
using namespace std;
int DecakismyriagonNum( int N)
{
return (99998 * N * N - 99996 * N)
/ 2;
}
int main()
{
int N = 3;
cout << DecakismyriagonNum(N);
return 0;
}
|
Java
class GFG{
static int DecakismyriagonNum( int N)
{
return ( 99998 * N * N - 99996 * N) / 2 ;
}
public static void main(String[] args)
{
int N = 3 ;
System.out.println(DecakismyriagonNum(N));
}
}
|
Python3
def DecakismyriagonNum(N):
return ( 99998 * N * N - 99996 * N) / / 2 ;
N = 3 ;
print (DecakismyriagonNum(N));
|
C#
using System;
class GFG{
static int DecakismyriagonNum( int N)
{
return (99998 * N * N - 99996 * N) / 2;
}
public static void Main()
{
int N = 3;
Console.Write(DecakismyriagonNum(N));
}
}
|
Javascript
<script>
function DecakismyriagonNum(N) {
return (99998 * N * N - 99996 * N) / 2;
}
let N = 3;
console.log(DecakismyriagonNum(N));
</script>
|
Time Complexity: O(1)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...