3 ms·
Java does still include some boilerplate for setting up classes — though that may go away in 10 when they add scripting. However, it is a lot more terse than in
by spullara 10y ago
Java does still include some boilerplate for setting up classes — though that may go away in 10 when they add scripting. However, it is a lot more terse than in 7:
package com.shekhargulati.ninetynine_problems._02_arithmetic;
import java.util.stream.LongStream;
/**
* (**) Determine whether a given integer number is prime.
*/
public class P31 {
public static boolean isPrime(long number) {
return !LongStream.rangeClosed(2, Math.round(Math.sqrt(number))).anyMatch(n -> number % n == 0);
}
}