Sorry - it must be:
int maxtest = (int) Math.sqrt(num)+1; return IntStream.range(2, maxtest).noneMatch(divider -> (num % divider) == 0);
The endvalue of then IntStrem can be the squareroot of num. If no lower divider is found, there is no at all!
int maxtest = (int) Math.sqrt(num); return IntStream.range(2, maxtest).noneMatch(divider -> (num % divider) == 0);
Thats much faster!
Loading collection data...
Sorry - it must be:
The endvalue of then IntStrem can be the squareroot of num. If no lower divider is found, there is no at all!
Thats much faster!