Liczby pierwsze

ZoooL
  • Rejestracja: dni
  • Ostatnio: dni
  • Postów: 62
0
Kopiuj
import java.math.BigInteger;

public class LiczbyPierwszeDziala {
    public static void main(String[] args) {
        BigInteger bi1, bi2, bi3;
        Boolean b1, b2, b3;

        bi1 = new BigInteger("2");
        bi2 = new BigInteger("4");
        bi3 = new BigInteger("5");

        b1 = bi1.isProbablePrime(1111111);
        b2 = bi2.isProbablePrime(1111111);
        b3 = bi3.isProbablePrime(0);

        String str1 = bi1+ " is prime with certainity 1 is " +b1;
        String str2 = bi2+ " is prime with certainity 1 is " +b2;
        String str3 = bi3+ " is prime with certainity -1 is " +b3;

        // print b1, b2, b3 values
        System.out.println( str1 );
        System.out.println( str2 );
        System.out.println( str3 );
    }
}

Mam taki programik z neta i chciałbym żeby mi ktoś powiedział co znaczą pogrubione liczby?
b1 = bi1.isProbablePrime(1);
b2 = bi2.isProbablePrime(-1);
b3 = bi3.isProbablePrime(0);

Shalom
  • Rejestracja: dni
  • Ostatnio: dni
  • Lokalizacja: Space: the final frontier
  • Postów: 26433
3

To są żarty?
https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/math/BigInteger.html#isProbablePrime(int)

public boolean isProbablePrime​(int certainty)
Returns true if this BigInteger is probably prime, false if it's definitely composite. If certainty is ≤ 0, true is returned.
Parameters:
certainty - a measure of the uncertainty that the caller is willing to tolerate: if the call returns true the probability that this BigInteger is prime exceeds (1 - 1/2certainty). The execution time of this method is proportional to the value of this parameter.
Returns:
true if this BigInteger is probably prime, false if it's definitely composite.

ZoooL
  • Rejestracja: dni
  • Ostatnio: dni
  • Postów: 62
0

ok dzięki i wszystko jasne
/close

Zarejestruj się i dołącz do największej społeczności programistów w Polsce.

Otrzymaj wsparcie, dziel się wiedzą i rozwijaj swoje umiejętności z najlepszymi.