require 
class Integer
  def safe_prime? 
    ((self-1)/2).prime?
  end
end

def format_parts(n)
  partitions = Prime.each(n).partition(&:safe_prime?).map(&:count)
  % partitions
end

puts 
p Prime.each.lazy.select(&:safe_prime?).take(35).to_a
puts format_parts(1_000_000),  

puts 
p Prime.each.lazy.reject(&:safe_prime?).take(40).to_a
puts format_parts(10_000_000)