Given a number **N**, the task is to print the **N ^{th}**

**Hogben number**.

Hogben Number:In a spiral arrangement of the integers,Hogben Numbersappear on the main diagonal (see the picture below).The first few Hogben numbers are 1, 3, 7, 13, 21, 31, 43, 57, 73, 91, 111, 133, 157, 183, 211, 241, 273……. and many more.

**Example:**

Input:N = 4

Output:3

Explanation:

The 4th Hogben number that lies on the diagonal of the spiral pattern is 13.

Input:N = 7

Output:43

Explanation:

The 7th Hogben number that lies on the diagonal of the spiral pattern is 43.

**Approach:**

We can observe from the sequence of Hogben numbers, that the **N ^{th}** Hogben number H

_{N}is equal to .

Below is the implementation of the above approach.

## C++

`// C++ program to print ` `// N-th Hogben Number ` ` ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function returns N-th ` `// Hogben Number ` `int` `HogbenNumber(` `int` `a) ` `{ ` ` ` `int` `p = (` `pow` `(a, 2) - a + 1); ` ` ` `return` `p; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `N = 10; ` ` ` ` ` `cout << HogbenNumber(N); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to print ` `// N-th Hogben Number ` `import` `java.util.*; ` ` ` `class` `GFG{ ` ` ` `// Function returns N-th ` `// Hogben Number ` `public` `static` `int` `HogbenNumber(` `int` `a) ` `{ ` ` ` `int` `p = (` `int` `)(Math.pow(a, ` `2` `) - a + ` `1` `); ` ` ` `return` `p; ` `} ` ` ` `// Driver code ` `public` `static` `void` `main(String args[]) ` `{ ` ` ` `int` `N = ` `10` `; ` ` ` ` ` `System.out.print(HogbenNumber(N)); ` `} ` `} ` ` ` `// This code is contributed by Akanksha_Rai ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to print ` `# N-th Hogben Number ` ` ` `# Function returns N-th ` `# Hogben Number ` `def` `HogbenNumber(a): ` ` ` ` ` `p ` `=` `(` `pow` `(a, ` `2` `) ` `-` `a ` `+` `1` `) ` ` ` `return` `p ` ` ` `# Driver code ` `N ` `=` `10` ` ` `print` `(HogbenNumber(N)) ` ` ` `# This code is contributed by shubhamsingh10 ` |

*chevron_right*

*filter_none*

## C#

`// C# program to print ` `// N-th Hogben Number ` `using` `System; ` `class` `GFG{ ` ` ` `// Function returns N-th ` `// Hogben Number ` `public` `static` `int` `HogbenNumber(` `int` `a) ` `{ ` ` ` `int` `p = (` `int` `)(Math.Pow(a, 2) - a + 1); ` ` ` `return` `p; ` `} ` ` ` `// Driver code ` `public` `static` `void` `Main() ` `{ ` ` ` `int` `N = 10; ` ` ` ` ` `Console.Write(HogbenNumber(N)); ` `} ` `} ` ` ` `// This code is contributed by Code_Mech ` |

*chevron_right*

*filter_none*

**Output:**

91

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:

- Find the Nth term of the Zumkeller Numbers
- Program to print tetrahedral numbers upto Nth term
- Program to print pentatope numbers upto Nth term
- Sum of all the numbers in the Nth row of the given triangle
- Program to find Nth term in the given Series
- Program to find the Nth term of the series 3, 7, 13, 21, 31.....
- Program to find Nth term of series 1, 3, 12, 60, 360…
- Program to find the Nth term of series -1, 2, 11, 26, 47......
- Program to find Nth term in the series 0, 0, 2, 1, 4, 2, 6, 3, 8,...
- Program to find Nth term of series 9, 23, 45, 75, 113...
- Program to find Nth term in the series 0, 2, 1, 3, 1, 5, 2, 7, 3,…
- Find Nth term of series 1, 4, 15, 72, 420...
- Find Nth term of the series 0, 2, 4, 8, 12, 18...
- Find Nth term of the series 5, 13, 25, 41, 61...
- Program to find the Nth term of the series 3, 20, 63, 144, 230, ……
- Program to find the Nth term of series 5, 10, 17, 26, 37, 50, 65, 82, ...
- Program to find the Nth term of series 0, 4, 14, 30, 51, 80, 114, 154, 200, ...
- Find Nth term of the series 3, 14, 39, 84...
- Program to find the Nth term of the series 0, 14, 40, 78, 124, ...
- Program to find the Nth term of the series 0, 5, 14, 27, 44, ........

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.