 fta = new Avg()
 fermat2_test = (n) ->
   fta.start()
+  #y = nbv(2).modPow(n.subtract(nbv(1)),n)
+  #ret = (y.compareTo(BigInteger.ONE) is 0)
+  #console.log(y.toString())
   t = nbv(1)
   bl = n.bitLength()
   bl--
   for i in [bl..0]
     t = t.modPowInt(2,n)
     #t = t.square()
-
     # .t in jsbn is equivalent to _mp_size in GNU bigint.  _mp_size
     # is the "number of limbs" in the bigint
     #if t.t > n.t

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

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

  # @return {BigInteger} the next weak prime
  #
  next_weak : () ->
    loop
      step = @sieve[@sievepos]
      @sievepos = (@sievepos + step) % @sieve.length
      @inc += step
      if @inc > @maxinc and @maxinc > 0
        @tmp = nbv(0)
        return @tmp
      @calcmods() if @inc < 0
      unless @decrement_mods_find_divisor()
        @tmp = @p.add nbv @inc
        return @tmp

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

