Created
December 31, 2014 21:35
-
-
Save tylertreat/37f44fc9d668f4b553b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static boolean isPrime(int p, int k) { | |
| Random rand = new Random(); | |
| for (int i = 0; i < k; i++) { | |
| int a = rand.nextInt(p - 1) + 1; | |
| int pow = (int) Math.pow(a, p - 1); | |
| if (pow % p != 1) | |
| return false; | |
| } | |
| return true; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment