 
 #-----------------------
 
-
 #
 # Find a random prime that is nbits long, with certainty
 # 1 - 2^{-iter}

# Use the sieve for primality testing, which in the case of regular odd
# primes is [1,2], and for strong primes is more interesting...
#
prime_search = (start, range, sieve, progress_hook, iters=20) ->
  pf = new PrimeFinder start, sieve
  pf.setmax range
  pvec = (pp while ((pp = pf.next_weak()).compareTo(BigInteger.ZERO) > 0))

  s = obj.p.toString()
  interval = if obj.total? and obj.i? then "(#{obj.i} of #{obj.total})" else ""
  console.log "+ #{obj.what} #{interval} #{s[0...3]}....#{s[(s.length-6)...]}"
await random_prime { nbits : 1024, iters : 10, progress_hook, e : nbv((1 << 16) + 1) }, defer p
console.log p.toString()
process.exit -1

