require 

RE = /(\d)(?=(\d\d\d)+(?!\d))/ 
cuban_primes = Enumerator.new do |y|
  (1..).each do |n|
    cand = 3*n*(n+1) + 1
    y << cand if OpenSSL::BN.new(cand).prime?
  end
end

def commatize(num)
  num.to_s.gsub(RE, )
end

cbs = cuban_primes.take(200)
formatted = cbs.map{|cb| commatize(cb).rjust(10) }
puts formatted.each_slice(10).map(&:join)

t0 = Time.now 
puts