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.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Find ratio of zeroes, positive numbers and negative numbers in the Array
- Given two numbers a and b find all x such that a % x = b
- Find two numbers whose sum and GCD are given
- Program to find LCM of two numbers
- Find LCM of rational numbers
- Find the XOR of first N Prime Numbers
- Program to find GCD or HCF of two numbers
- Find max of two Rational numbers
- Find the numbers from 1 to N that contains exactly k non-zero digits
- Find k numbers which are powers of 2 and have sum N | Set 1
- Find two numbers with sum N such that neither of them contains digit K
- Find the sum of first N odd Fibonacci numbers
- Find two numbers with sum and product both same as N
- Find the sum of the all amicable numbers up to N
- Find the sum of the first N Dodecagonal Numbers
- Find XOR of numbers from the range [L, R]
- Program to find LCM of 2 numbers without using GCD
- Find two prime numbers with given sum
- Find the sum of the first Nth Icosagonal Numbers
- Find three prime numbers with given sum
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.