We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Considering the input type is String.
So, first constructing a new object of BigInteger without referecing it to BigInteger type variable and then calling the suggested method on that.
System.out.println(new BigInteger(n).isProbablePrime(1) ? "prime" : "not prime");
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Primality Test
You are viewing a single comment's thread. Return to all comments →
Considering the input type is String. So, first constructing a new object of BigInteger without referecing it to BigInteger type variable and then calling the suggested method on that.
System.out.println(new BigInteger(n).isProbablePrime(1) ? "prime" : "not prime");