Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!
Can you fill the blanks in the code to check if a number is prime? The program should print "Prime" if the number is prime, and "Not Prime" otherwise.For loop
Number detective seeks elusive primes
Report a typo
Fill in the gaps with the relevant elements
int n = 17;
boolean isPrime = true;
(int i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0) {
isPrime = false;
;
}
}
System.out.println(isPrime ? "Prime" : "Not Prime");Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.