We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6149ec7 commit 2bb44faCopy full SHA for 2bb44fa
src/main/java/com/thealgorithms/maths/Prime/PrimeCheck.java
@@ -1,5 +1,6 @@
1
package com.thealgorithms.maths.Prime;
2
3
+import java.math.BigInteger;
4
import java.util.Scanner;
5
6
public final class PrimeCheck {
@@ -22,6 +23,12 @@ public static void main(String[] args) {
22
23
} else {
24
System.out.println("algo2 verify that " + n + " is not a prime number");
25
}
26
+
27
+ if (BigInteger.valueOf(n).isProbablePrime(100)){ // uses Miller–Rabin and Lucas probable prime test (Baillie–PSW)
28
+ System.out.println("algo3 verify that " + n + " is a prime number");
29
+ } else {
30
+ System.out.println("algo3 verify that " + n + " is not a prime number");
31
+ }
32
scanner.close();
33
34
0 commit comments