Question: Create a Java recursive method that determines if a number is a prime number. Naming: Do the following: Create a recursive method computePrime(int x,
Create a Java recursive method that determines if a number is a prime number. Naming: Do the following: Create a recursive method computePrime(int x, int y) that returns a boolean value. Returns true if x is prime, else returns false. y is current divisor to check. Ask the user to enter a number to check to see if it is a prime. First call from main, set y equal to 2. Example: primeno = computePrime(number, 2); Name the Java project: LastFProject Name the driver program (main): LastF.java Save in a file folder on your storage device. Base cases if x < 2 return false if x == 2 return true if x % y == 0 return false if y*y> x return true // Otherwise, Check for next divisor O return computePrime(x, y + 1) Demonstrate the method in a program. (Same or separate program.) Test the program and make sure it runs. I want to see comments and descriptive variable names throughout your program!!!!
Step by Step Solution
3.40 Rating (150 Votes )
There are 3 Steps involved in it
Below is the Java code for your requirements Filename LastFProjectLastFjava import javautilScanner p... View full answer
Get step-by-step solutions from verified subject matter experts
