1. Feng Zhou
  2. miller_rabin

Commits

Feng Zhou  committed 226143f

edited comments

  • Participants
  • Parent commits a4df926
  • Branches default

Comments (0)

Files changed (1)

File miller_rabin.py

View file
-# isprime(n) tests whether the n is a prime number using the Miller-Rabin primality test.
-# input: an integer
-# output: Boolean
-
 from math import log, pow
 
+# two conditions
+# if a number meets one of them, it's likely a prime number.
+# otherwise it's a composite number.
 def iscond1(b, k, n):
     if ((pow(b, k)) % n == 1):
         return True
             return True
     return False
 
+# isprime(n) tests whether the n is a prime number using the Miller-Rabin primality test.
+# input: an integer
+# output: Boolean
 def isprime(n):
-    b = 3
+    b = 3 # b is a random number between 0 and n-1
     k = 1
     while (k <= (n - 1)):
         q = log(((n - 1) / k), 2)
         k += 2
     print n, "is not a prime number.\n"
     return False
-