     for sp,i in small_primes
       while (@mods[i] + @inc >= sp)
         @mods[i] -= sp
-        return true if (@mods[i] + @inc) is 0
+        if (@mods[i] + @inc) is 0
+          return true 
     return false
 
   #-----------------------

    t = t.mod(n)
  #console.log t.toString()
  ret = (t.compareTo(nbv(2)) is 0)
  ret

#--------------

exports.miller_rabin = miller_rabin
exports.random_prime = random_prime

#=================================================================

progress_hook = (obj) ->
  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 3072, 10, defer(p), progress_hook
console.log p.toString()
process.exit -1

