Given an integer **N**, the task is to check if it is a Tridecagonal number or not.

Tridecagon numberis a thirteen-sided polygon. The first few Tridecagon numbers are 1, 13, 36, 70, 115, 171, …

**Examples:**

Input:N = 13

Output:Yes

Explanation:

Second Tridecagon number is 13.

Input:N = 30

Output:No

**Approach:**

- The K
^{th}term of the Tridecagon number is given as - As we have to check that the given number can be expressed as a Tridecagon number or not. This can be checked as follows –

=>

=> - Finally, check the value of computed using this formulae is an integer, which means that N is a Tridecagon number.

Below is the implementation of the above approach:

## C++

`// C++ implementation to check that ` `// a number is a Tridecagon number or not ` ` ` `#include <bits/stdc++.h> ` ` ` `using` `namespace` `std; ` ` ` `// Function to check that the ` `// number is a Tridecagon number ` `bool` `isTridecagon(` `int` `N) ` `{ ` ` ` `float` `n ` ` ` `= (9 + ` `sqrt` `(88 * N + 81)) ` ` ` `/ 22; ` ` ` ` ` `// Condition to check if the ` ` ` `// number is a Tridecagon number ` ` ` `return` `(n - (` `int` `)n) == 0; ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` ` ` `int` `i = 13; ` ` ` ` ` `// Function call ` ` ` `if` `(isTridecagon(i)) { ` ` ` `cout << ` `"Yes"` `; ` ` ` `} ` ` ` `else` `{ ` ` ` `cout << ` `"No"` `; ` ` ` `} ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java implementation to check that a ` `// number is a tridecagon number or not ` `class` `GFG{ ` ` ` `// Function to check that the ` `// number is a tridecagon number ` `static` `boolean` `isTridecagon(` `int` `N) ` `{ ` ` ` `float` `n = (` `float` `) ((` `9` `+ Math.sqrt(` `88` `* N + ` ` ` `81` `)) / ` `22` `); ` ` ` ` ` `// Condition to check if the ` ` ` `// number is a tridecagon number ` ` ` `return` `(n - (` `int` `)n) == ` `0` `; ` `} ` ` ` `// Driver Code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` `int` `i = ` `13` `; ` ` ` ` ` `// Function call ` ` ` `if` `(isTridecagon(i)) ` ` ` `{ ` ` ` `System.out.print(` `"Yes"` `); ` ` ` `} ` ` ` `else` ` ` `{ ` ` ` `System.out.print(` `"No"` `); ` ` ` `} ` `} ` `} ` ` ` `// This code is contributed by 29AjayKumar ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 implementation to check that ` `# a number is a tridecagon number or not ` `import` `math ` ` ` `# Function to check that the ` `# number is a tridecagon number ` `def` `isTridecagon(N): ` ` ` ` ` `n ` `=` `(` `9` `+` `math.sqrt(` `88` `*` `N ` `+` `81` `)) ` `/` `22` ` ` ` ` `# Condition to check if the ` ` ` `# number is a tridecagon number ` ` ` `return` `(n ` `-` `int` `(n)) ` `=` `=` `0` ` ` `# Driver Code ` `i ` `=` `13` ` ` `# Function call ` `if` `(isTridecagon(i)): ` ` ` `print` `(` `"Yes"` `) ` `else` `: ` ` ` `print` `(` `"No"` `) ` ` ` `# This code is contributed by divyamohan123 ` |

*chevron_right*

*filter_none*

## C#

`// C# implementation to check that a ` `// number is a tridecagon number or not ` `using` `System; ` ` ` `class` `GFG{ ` ` ` `// Function to check that the ` `// number is a tridecagon number ` `static` `bool` `isTridecagon(` `int` `N) ` `{ ` ` ` `float` `n = (` `float` `)((9 + Math.Sqrt(88 * N + ` ` ` `81)) / 22); ` ` ` ` ` `// Condition to check if the ` ` ` `// number is a tridecagon number ` ` ` `return` `(n - (` `int` `)n) == 0; ` `} ` ` ` `// Driver Code ` `public` `static` `void` `Main() ` `{ ` ` ` `int` `i = 13; ` ` ` ` ` `// Function call ` ` ` `if` `(isTridecagon(i)) ` ` ` `{ ` ` ` `Console.Write(` `"Yes"` `); ` ` ` `} ` ` ` `else` ` ` `{ ` ` ` `Console.Write(` `"No"` `); ` ` ` `} ` `} ` `} ` ` ` `// This code is contributed by Code_Mech ` |

*chevron_right*

*filter_none*

**Output:**

Yes

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.

## Recommended Posts:

- Program to check if N is a Centered Tridecagonal Number
- Centered tridecagonal number
- Tridecagonal Number
- Find the sum of the first Nth Centered Tridecagonal Numbers
- Program to check whether a number is Proth number or not
- Recursive program to check if number is palindrome or not
- Program to check if N is a Hexagonal Number or not
- Program to check if N is a Centered Pentagonal Number or not
- C Program to check whether a number is a Perfect Cube or not
- Check if a number is a Krishnamurthy Number or not
- Check Whether a number is Duck Number or not
- Check if given number is Emirp Number or not
- Check if a number with even number of digits is palindrome or not
- Check whether the given number is Euclid Number or not
- Check if the given number is Ore number or not
- Check if a number is an Unusual Number or not
- Check if a number is an Achilles number or not
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Check whether given number N is a Moran Number or not
- Check whether a given number N is a Nude Number or not

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.