require 'prime'

def num_divisors(n)
  n.prime_division.inject(1){|prod, (_p,n)| prod *= (n + 1) } 
end

anti_primes = Enumerator.new do |y| 
  max = 0
  y << 1                            
  2.step(nil,2) do |candidate|      
     num = num_divisors(candidate)
     if  num > max
       y << candidate               
       max = num
     end
  end
end

puts anti_primes.take(20).join()