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
Output: 12
The second Zumkeller number is 12.

Input: N = 5
Output: 28

Approach: The following steps are followed to compute the answer.

  1. Get the number N.
  2. Iterate over the loop starting from i = 1 until Nth Zumkeller number is found.
  3. Check the number ‘i’ is a zumkeller number or not.
  4. If yes, then repeat the above step for i+1 and increment the counter.
  5. If no, then repeat the above step for i+1 without incrementing the counter.
  6. 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:






# Python program to find the
# N-th Zumkeller number
# Function to find all the
# divisiors
def Divisors(n) : 
    l = []
    i = 1
    while i <= n : 
        if (n % i == 0) : 
        i = i + 1
    return l
# Function to check if the sum 
# of the subset of divisors is
# equal to sum / 2 or not
def PowerSet(arr, n, s): 
    # List to find all the 
    # subsets of the given set. 
    # Any repeated subset is 
    # considered only  
    # once in the output 
    _list = [] 
    # Run a counter i  
    for i in range(2**n): 
        subset = "" 
        # Consider each element 
        # in the set 
        for j in range(n): 
            # Check if j-th bit in 
            # the i is set.  
            # If the bit is set, 
            # we consider  
            # j-th element from set 
            if (i & (1 << j)) != 0
                subset += str(arr[j]) + "|"
        # Check if the subset is 
        # encountered for the first time. 
        if subset not in _list and len(subset) > 0
    # Consider every subset 
    for subset in _list: 
        sum = 0
        # Split the subset and 
        # sum of its elements 
        arr = subset.split('|'
        for string in arr[:-1]: 
            sum += int(string)
            # If the sum is equal
            # to S
            if sum == s:
                return True
    return False
# Function to check if a number 
# is a Zumkeller number
def isZumkeller(n):
    # To find all the divisors 
    # of a number N
    d = Divisors(n)
    # Finding the sum of
    # all the divisors
    s = sum(d)
    # Check for the condition that 
    # sum must be even and the 
    # maximum divisor is less than
    # or equal to sum / 2. 
    # If the sum is odd and the 
    # maximum divisor is greater than
    # sum / 2, then it is not possible 
    # to divide the divisors into 
    # two sets
    if not s % 2 and max(d) <= s / 2:
        # For all the subsets of
        # the divisors
        if PowerSet(d, len(d), s / 2) :
                return True
    return False
# Function to print N-th 
# Zumkeller number
def printZumkellers(N):
    val = 0
    ans = 0
    # Iterating through all
    # the numbers
    for n in range(1, 10**5):
        # Check if n is a 
        # Zumkeller number
        if isZumkeller(n):
            ans = n
            val += 1
            # Check if N-th Zumkeller number
            # is obtained or not
            if val >= N:
# Driver code
if __name__ == '__main__':
    N = 4




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.

My Personal Notes arrow_drop_up

Small things always make you to think big

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to 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.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.