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

Hendecagonal Numberis a figurate number that extends the concept of triangular and square numbers to the decagon(11-sided polygon). Thenthhendecagonal number counts the number of dots in a pattern of n nested decagons, all sharing a common corner, where theithhendecagon in the pattern has sides made ofi dotsspaced one unit apart from each other. The first few hendecagonal numbers are1, 11, 30, 58, 95, 141…

**Examples:**

Input:N = 11Output:YesExplanation:

Second hendecagonal number is 11.Input:N = 40Output:No

**Approach:**

- The
**K**term of the Hendecagonal Number is given as^{th}

- As we have to check that the given number can be expressed as a
**Hendecagonal 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 Hendecagonal Number. - Else
**N**is not a Hendecagonal 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` `// Hendecagonal Number` `bool` `ishendecagonal(` `int` `N)` `{` ` ` `float` `n` ` ` `= (7 + ` `sqrt` `(72 * N + 49))` ` ` `/ 18;` ` ` `// Condition to check if the` ` ` `// number is a hendecagonal number` ` ` `return` `(n - (` `int` `)n) == 0;` `}` `// Driver Code` `int` `main()` `{` ` ` `// Given Number` ` ` `int` `N = 11;` ` ` `// Function call` ` ` `if` `(ishendecagonal(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` `// hendecagonal number` `public` `static` `boolean` `ishendecagonal(` `int` `N)` `{` ` ` `double` `n = (` `7` `+ Math.sqrt(` `72` `* N + ` `49` `)) / ` `18` `;` ` ` ` ` `// Condition to check if the` ` ` `// number is a hendecagonal number` ` ` `return` `(n - (` `int` `)n) == ` `0` `;` `}` `// Driver code ` `public` `static` `void` `main(String[] args)` `{` ` ` ` ` `// Given number` ` ` `int` `N = ` `11` `;` ` ` ` ` `// Function call` ` ` `if` `(ishendecagonal(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` `# Hendecagonal Number` `def` `ishendecagonal(N):` ` ` `n ` `=` `(` `7` `+` `math.sqrt(` `72` `*` `N ` `+` `49` `))` `/` `/` `18` `;` ` ` `# Condition to check if the` ` ` `# number is a hendecagonal number` ` ` `return` `(n ` `-` `int` `(n)) ` `=` `=` `0` `;` `# Driver Code` `# Given Number` `N ` `=` `11` `;` `# Function call` `if` `(ishendecagonal(N)):` ` ` `print` `(` `"Yes"` `);` `else` `:` ` ` `print` `(` `"No"` `);` `# This code is contributed by Nidhi_biet` |

## C#

`// C# program for the above approach` `using` `System;` `class` `GFG{` ` ` `// Function to check if N is a` `// hendecagonal number` `public` `static` `bool` `ishendecagonal(` `int` `N)` `{` ` ` `double` `n = (7 + Math.Sqrt(72 * N + 49)) / 18;` ` ` ` ` `// Condition to check if the` ` ` `// number is a hendecagonal number` ` ` `return` `(n - (` `int` `)n) == 0;` `}` `// Driver code` `public` `static` `void` `Main(` `string` `[] args)` `{` ` ` ` ` `// Given number` ` ` `int` `N = 11;` ` ` ` ` `// Function call` ` ` `if` `(ishendecagonal(N))` ` ` `{` ` ` `Console.Write(` `"Yes"` `);` ` ` `}` ` ` `else` ` ` `{` ` ` `Console.Write(` `"No\n"` `);` ` ` `}` `}` `}` `// This code is contributed by rutvik_56` |

## Javascript

`<script>` `// javascript program for the above approach` `// Function to check if N is a` `// Hendecagonal Number` `function` `ishendecagonal( N)` `{` ` ` `let n` ` ` `= (7 + Math.sqrt(72 * N + 49))` ` ` `/ 18;` ` ` `// Condition to check if the` ` ` `// number is a hendecagonal number` ` ` `return` `(n - parseInt(n)) == 0;` `}` `// Driver Code` ` ` `// Given Number` ` ` `let N = 11;` ` ` `// Function Call` ` ` `if` `(ishendecagonal(N)) {` ` ` `document.write( ` `"Yes"` `);` ` ` `}` ` ` `else` `{` ` ` `document.write( ` `"No"` `);` ` ` `}` `// This code contributed by gauravrajput1` `</script>` |

**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. 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 industry experts, please refer **Geeks Classes Live**