Find the Nth term of the Zumkeller Numbers
Zumkeller numbers are the set of numbers whose divisors can be partitioned into two disjoint sets that sum to the same value. The first few zumkeller numbers are 6, 12, 20, 24, 28, 30, 40, 42, 48, 54, ….
In this article, we will find the Nth Zumkeller number.
Find the Nth Zumkeller Number: Given a number N, the task is to find the Nth Zumkeller number.
Input: N = 2
The second Zumkeller number is 12.
Input: N = 5
Approach: The following steps are followed to compute the answer.
- Get the number N.
- Iterate over the loop starting from i = 1 until Nth Zumkeller number is found.
- Check the number ‘i’ is a zumkeller number or not.
- If yes, then repeat the above step for i+1 and increment the counter.
- If no, then repeat the above step for i+1 without incrementing the counter.
- Finally, when the counter is equal to the number N, that number is the N-th zumkeller number. Print the value of ‘i’ and break the loop.
Below is the implementation of the above approach:
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.