# Program to check if N is a Tetradecagonal Number

Given an integer **N**, the task is to check if **N** is a Tetradecagonal Number or not. If the number **N** is an Tetradecagonal Number then print **“Yes”** else print **“No”**.

Tetradecagonal Numberis14-sided polygoncalled Tetrakaidecagon or Tetradecagon and belongs to the figurative number. Thenthtetradecagonal number doted with some dots and create a series of the pattern. They have a common sharing corner point and doted with their spaces to each other. The dots continue withnthnested loop.The first few Tetradecagonal Numbers are1, 14, 39, 76, 125, 186, …

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the

DSA Self Paced Courseat a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please referComplete Interview Preparation Course.In case you wish to attend

live classeswith experts, please referDSA Live Classes for Working ProfessionalsandCompetitive Programming Live for Students.

**Examples:**

Input:N = 14Output:YesExplanation:

Second tetradecagonal number is 14.Input:N = 40Output:No

**Approach:**

- The
**K**term of the tetradecagonal number is given as^{th}

- As we have to check that the given number can be expressed as a Tetradecagonal Number or not. This can be checked as:

=>

=>

- If the value of
**K**calculated using the above formula is an integer, then**N**is a Tetradecagonal Number. - Else
**N**is not a Tetradecagonal Number.

Below is the implementation of the above approach:

## C++

`// C++ program for the above approach` `#include <bits/stdc++.h>` `using` `namespace` `std;` `// Function to check if N is a` `// Tetradecagonal Number` `bool` `istetradecagonal(` `int` `N)` `{` ` ` `float` `n` ` ` `= (10 + ` `sqrt` `(96 * N + 100))` ` ` `/ 24;` ` ` `// Condition to check if the` ` ` `// number is a tetradecagonal number` ` ` `return` `(n - (` `int` `)n) == 0;` `}` `// Driver Code` `int` `main()` `{` ` ` `// Given Number` ` ` `int` `N = 11;` ` ` `// Function call` ` ` `if` `(istetradecagonal(N)) {` ` ` `cout << ` `"Yes"` `;` ` ` `}` ` ` `else` `{` ` ` `cout << ` `"No"` `;` ` ` `}` ` ` `return` `0;` `}` |

## Java

`// Java program for the above approach` `import` `java.lang.Math;` `class` `GFG{` ` ` `// Function to check if N is a` `// tetradecagonal number` `public` `static` `boolean` `istetradecagonal(` `int` `N)` `{` ` ` `double` `n = (` `10` `+ Math.sqrt(` `96` `* N +` ` ` `100` `)) / ` `24` `;` ` ` ` ` `// Condition to check if the number` ` ` `// is a tetradecagonal number` ` ` `return` `(n - (` `int` `)n) == ` `0` `;` `}` `// Driver Code ` `public` `static` `void` `main(String[] args)` `{` ` ` ` ` `// Given number` ` ` `int` `N = ` `11` `;` ` ` ` ` `// Function call` ` ` `if` `(istetradecagonal(N))` ` ` `{` ` ` `System.out.println(` `"Yes"` `);` ` ` `}` ` ` `else` ` ` `{` ` ` `System.out.println(` `"No"` `);` ` ` `}` `}` `}` `// This code is contributed by divyeshrabadiya07 ` |

## Python3

`# Python3 program for the above approach` `import` `math` `# Function to check if N is a` `# Tetradecagonal Number` `def` `istetradecagonal(N):` ` ` ` ` `n ` `=` `(` `10` `+` `math.sqrt(` `96` `*` `N ` `+` `100` `)) ` `/` `24` ` ` ` ` `# Condition to check if the` ` ` `# number is a tetradecagonal number` ` ` `if` `(n ` `-` `int` `(n)) ` `=` `=` `0` `:` ` ` `return` `True` ` ` ` ` `return` `False` `# Driver Code` `# Given Number` `N ` `=` `11` `# Function call` `if` `(istetradecagonal(N)):` ` ` `print` `(` `"Yes"` `)` `else` `:` ` ` `print` `(` `"No"` `)` `# This code is contributed by shubhamsingh10` |

## C#

`// C# program for the above approach` `using` `System;` `class` `GFG{` ` ` `// Function to check if N is a` `// tetradecagonal number` `public` `static` `bool` `istetradecagonal(` `int` `N)` `{` ` ` `double` `n = (10 + Math.Sqrt(96 * N +` ` ` `100)) / 24;` ` ` ` ` `// Condition to check if the number` ` ` `// is a tetradecagonal number` ` ` `return` `(n - (` `int` `)n) == 0;` `}` ` ` `// Driver Code` `static` `public` `void` `Main ()` `{` ` ` ` ` `// Given number` ` ` `int` `N = 11;` ` ` ` ` `// Function call` ` ` `if` `(istetradecagonal(N))` ` ` `{` ` ` `Console.Write(` `"Yes"` `);` ` ` `}` ` ` `else` ` ` `{` ` ` `Console.Write(` `"No"` `);` ` ` `}` `}` `}` `// This code is contributed by shubhamsingh10` |

## Javascript

`<script>` `// Javascript program for the above approach` `// Function to check if N is a` `// Tetradecagonal Number` `function` `istetradecagonal(N)` `{` ` ` `n = (10 + Math.sqrt(96 * N + 100))` ` ` `/ 24;` ` ` `// Condition to check if the` ` ` `// number is a tetradecagonal number` ` ` `return` `(n - parseInt(n)) == 0;` `}` `// Driver Code` `// Given Number` `N = 11;` `// Function call` `if` `(istetradecagonal(N)) {` ` ` `document.write(` `"Yes"` `);` `}` `else` `{` ` ` `document.write(` `"No"` `);` `}` ` ` `</script>` |

**Output:**

No

**Time Complexity: **O(1)

**Auxiliary Space: **O(1)