Zumkeller numbers are the set of numbers whose divisors can be partitioned into two disjoint sets that sum to the same value. Each sum must contain divisor values that are not in the other sum, and all of the divisors must be in one or the other. There are no restrictions on how the divisors are partitioned, only that the two partition sums are equal.



E.G.
 6 is a Zumkeller number; The divisors {1 2 3 6} can be partitioned into two groups {1 2 3} and {6} that both sum to 6.
 10 is not a Zumkeller number; The divisors {1 2 5 10} can not be partitioned into two groups in any way that will both sum to the same value.
 12 is a Zumkeller number; The divisors {1 2 3 4 6 12} can be partitioned into two groups {1 3 4 6} and {2 12} that both sum to 14.


Even Zumkeller numbers are common; odd Zumkeller numbers are much less so. For values below 10^6, there is at least one Zumkeller number in every 12 consecutive integers, and the vast majority of them are even. The odd Zumkeller numbers are very similar to the list from the task Abundant odd numbers; they are nearly the same except for the further restriction that the abundance (A(n) = sigma(n) - 2n), must be even: A(n) mod 2 == 0



Task

 Write a routine (function, procedure, whatever) to find Zumkeller numbers.
 Use the routine to find and display here, on this page, the first 220 Zumkeller numbers.
 Use the routine to find and display here, on this page, the first 40 odd Zumkeller numbers.
 Optional, stretch goal: Use the routine to find and display here, on this page, the first 40 odd Zumkeller numbers that don't end with 5.


See Also

 OEIS:A083207 - Zumkeller numbers to get an impression of different partitions OEIS:A083206 Zumkeller partitions
 OEIS:A174865 - Odd Zumkeller numbers


Related Tasks

 Abundant odd numbers
 Abundant, deficient and perfect number classifications
 Proper divisors , Factors of an integer
# The factors, sorted
def factors:
  . as $num
  | reduce range(1; 1 + sqrt|floor) as $i
      ([];
       if ($num % $i) == 0 then
         ($num / $i) as $r
         | if $i == $r then . + [$i] else . + [$i, $r] end
       else . 
       end
       | sort) ;
 
# If the input is a sorted array of distinct non-negative integers,
# then the output will be a stream of [$x,$y] arrays,
# where $x and $y are non-empty arrays that partition the
# input, and where ($x|add) == $sum.
# If [$x,$y] is emitted, then [$y,$x] will not also be emitted.
# The items in $x appear in the same order as in the input, and similarly
# for $y.
#
def distinct_partitions($sum):
  # input: [$array, $n, $lim] where $n>0
  # output: a stream of arrays, $a, each with $n distinct items from $array,
  #         preserving the order in $array, and such that
  #         add == $lim
  def p:
     . as [$in, $n, $lim]
     | if $n==1  # this condition is very common so it saves time to check early on
       then ($in | bsearch($lim)) as $ix
       | if $ix < 0 then empty
         else [$lim]
         end
       else ($in|length) as $length
       | if $length <= $n then empty
         elif $length==$n            then $in | select(add == $lim)
         elif ($in[-$n:]|add) < $lim then empty
         else  ($in[:$n]|add) as $rsum
         | if $rsum > $lim      then empty 
           elif $rsum == $lim   then "amazing" | debug | $in[:$n]
           else range(0; 1 + $length - $n) as $i
           | [$in[$i]] + ([$in[$i+1:], $n-1, $lim - $in[$i]]|p)
           end
         end
       end;
 
  range(1; (1+length)/2) as $i
  | ([., $i, $sum]|p) as $pi
  | [ $pi, (. - $pi)]
  | select( if (.[0]|length) == (.[1]|length) then (.[0] < .[1]) else true end) #1
  ;
 
def zumkellerPartitions:
  factors
  | add as $sum
  | if $sum % 2 == 1 then empty
    else distinct_partitions($sum / 2)
    end;
 
def is_zumkeller:
  first(factors
        | add as $sum
        | if $sum % 2 == 1 then empty
          else distinct_partitions($sum / 2)
	  | select( (.[0]|add) == (.[1]|add)) // ("internal error: \(.)" | debug | empty)  #2
	  end
	| true)
  // false;