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.
My takeaway here is to not trust the hackerrank editor's rendering of Javadocs... As viewed through hackerrank, the Javadoc for BigInteger.isProbablePrime(int) states that "if the call returns true the probability that this BigInteger is prime exceeds (1 - 1/2certainty)", which certainly looks like it was intended to mean probability > 1 - (1/2) * certainty. However, viewing the Javadoc on Oracle's website makes it much more clear that what was actually meant was probability > 1 - (1/2) ^ certainty...
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 →
My takeaway here is to not trust the hackerrank editor's rendering of Javadocs... As viewed through hackerrank, the Javadoc for BigInteger.isProbablePrime(int) states that "if the call returns true the probability that this BigInteger is prime exceeds (1 - 1/2certainty)", which certainly looks like it was intended to mean probability > 1 - (1/2) * certainty. However, viewing the Javadoc on Oracle's website makes it much more clear that what was actually meant was probability > 1 - (1/2) ^ certainty...