 # 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) ->
+prime_search = ({start, range, sieve, progress_hook, iters}) ->
+  iters or= 20
   pf = new PrimeFinder start, sieve
   pf.setmax range
   pvec = (pp while ((pp = pf.next_weak()).compareTo(BigInteger.ZERO) > 0))

# @param {number} iters The number of time to run Miller-Rabin
# @param {callback} Callback with the {BigInteger} result
# @param {function} progress_hook A hook to call to update progress
#
random_prime = (nbits, iters, cb, progress_hook) ->
  srf = new StrongRandomFountain()
  sieve = [1,2]
  go = true

  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

