Skip to content

Instantly share code, notes, and snippets.

@tylertreat
Created December 31, 2014 21:35
Show Gist options
  • Select an option

  • Save tylertreat/37f44fc9d668f4b553b3 to your computer and use it in GitHub Desktop.

Select an option

Save tylertreat/37f44fc9d668f4b553b3 to your computer and use it in GitHub Desktop.
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