Skip to content

Instantly share code, notes, and snippets.

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

  • Save tylertreat/8b5c1c4e53aa009f2ba5 to your computer and use it in GitHub Desktop.

Select an option

Save tylertreat/8b5c1c4e53aa009f2ba5 to your computer and use it in GitHub Desktop.
public static boolean isPrime(int p) {
Random rand = new Random();
int a = rand.nextInt(p - 1) + 1;
int pow = (int) Math.pow(a, p - 1);
return pow % p == 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment