JAVA Code: Complete the method, isPrime(). The method takes in a positive integer, n > 1. The method should return a boolean that is true
JAVA Code:
Complete the method, isPrime(). The method takes in a positive integer, n > 1. The method should return a boolean that is true if n is a prime number, false if it is not. Recall that a positive integer greater than 1 is prime if and only if it is only divisible by 1 and itself. For example, 17 is prime because it is only divisible by 1 and 17. 9 is NOT prime because it is divisible by 1, 3, and 9. 2 is the smallest prime number.
You may assume the argument, n, is an integer greater than 1.
Starter Code:
public class Prime { public static boolean isPrime(int n) { //TODO: complete this method } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started