Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!