Find the Nth Hogben Numbers
Given a number N, the task is to print the Nth Hogben number.
Hogben Number: In a spiral arrangement of the integers, Hogben Numbers appear 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.
Input: N = 4
The 4th Hogben number that lies on the diagonal of the spiral pattern is 13.
Input: N = 7
The 7th Hogben number that lies on the diagonal of the spiral pattern is 43.
We can observe from the sequence of Hogben numbers, that the Nth Hogben number HN is equal to .
Below is the implementation of the above approach.
Attention reader! Don’t stop learning now. Join the First-Step-to-DSA Course for Class 9 to 12 students , specifically designed to introduce data structures and algorithms to the class 9 to 12 students