parameters: (n, rounds, randfunc=None)
return_statement: return 1
docstring: _rabinMillerTest(n:long, rounds:int, randfunc:callable):int
      Tests if n is prime.
      Returns 0 when n is definitely composite.
      Returns 1 when n is probably prime.
      Returns 2 when n is definitely prime.
  
      If randfunc is omitted, then Random.new().read is used.
  
      This function is for internal use only and may be renamed or removed in
      the future.
docstring_summary: _rabinMillerTest(n:long, rounds:int, randfunc:callable):int
      Tests if n is prime.
      Returns 0 when n is definitely composite.
      Returns 1 when n is probably prime.
      Returns 2 when n is definitely prime.
docstring_tokens: _rabinMillerTest ( n : long rounds : int randfunc : callable ) : int Tests if n is prime . Returns 0 when n is definitely composite . Returns 1 when n is probably prime . Returns 2 when n is definitely prime .
function: def _rabinMillerTest(n, rounds, randfunc=None):
      """_rabinMillerTest(n:long, rounds:int, randfunc:callable):int
      Tests if n is prime.
      Returns 0 when n is definitely composite.
      Returns 1 when n is probably prime.
      Returns 2 when n is definitely prime.
  
      If randfunc is omitted, then Random.new().read is used.
  
      This function is for internal use only and may be renamed or removed in
      the future.
      """
      # check special cases (n==2, n even, n < 2)
      if n < 3 or (n & 1) == 0:
          return n == 2
      # n might be very large so it might be beneficial to precalculate n-1
      n_1 = n - 1
      # determine m and b so that 2**b * m = n - 1 and b maximal
      b = 0
      m = n_1
      while (m & 1) == 0:
          b += 1
          m >>= 1
  
      tested = []
      # we need to do at most n-2 rounds.
      for i in iter_range (min (rounds, n-2)):
          # randomly choose a < n and make sure it hasn't been tested yet
          a = getRandomRange (2, n, randfunc)
          while a in tested:
              a = getRandomRange (2, n, randfunc)
          tested.append (a)
          # do the rabin-miller test
          z = pow (a, m, n) # (a**m) % n
          if z == 1 or z == n_1:
              continue
          composite = 1
          for r in iter_range(b):
              z = (z * z) % n
              if z == 1:
                  return 0
              elif z == n_1:
                  composite = 0
                  break
          if composite:
              return 0
      return 1
function_tokens: def _rabinMillerTest ( n , rounds , randfunc = None ) : # check special cases (n==2, n even, n < 2) if n < 3 or ( n & 1 ) == 0 : return n == 2 # n might be very large so it might be beneficial to precalculate n-1 n_1 = n - 1 # determine m and b so that 2**b * m = n - 1 and b maximal b = 0 m = n_1 while ( m & 1 ) == 0 : b += 1 m >>= 1 tested = [ ] # we need to do at most n-2 rounds. for i in iter_range ( min ( rounds , n - 2 ) ) : # randomly choose a < n and make sure it hasn't been tested yet a = getRandomRange ( 2 , n , randfunc ) while a in tested : a = getRandomRange ( 2 , n , randfunc ) tested . append ( a ) # do the rabin-miller test z = pow ( a , m , n ) # (a**m) % n if z == 1 or z == n_1 : continue composite = 1 for r in iter_range ( b ) : z = ( z * z ) % n if z == 1 : return 0 elif z == n_1 : composite = 0 break if composite : return 0 return 1