1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
creativ13 [48]
3 years ago
8

Write a recursive function to determine if a number is prime.

Computers and Technology
1 answer:
Darya [45]3 years ago
6 0

Answer:

Follows are the code to find the prime number:

import java.util.*;//import package for user input  

public class Main//defining a class

{  

public static boolean Prime(int x, int j)//defining a method isPrime    

   {  

       if (x<= 2) //use if block to check x less than equal to 2

           return (x== 2) ? true : false; //use bitwise operator to return value  

       if (x%j == 0) //use if to check x%j equal to 0

           return false;//return false value  

       if (j*j > x)//defining if that check i square value greater than n  

           return true; //return true value

       return Prime(x, j+1); //callling recursive method

   }  

   public static void main(String[] as)//main method  

   {  

       int n; //defining integer variable

       Scanner oxc=new Scanner(System.in);//creating Scanner class object

       n=oxc.nextInt();//input value

       if (Prime(n, 2))  //use if block to call isPrime method

           System.out.println("Yes"); //print value  

       else //else block

           System.out.println("No");  //print value  

   }  

}  

Output:

5

Yes

Explanation:

In this code, a static boolean method "Prime" is declared, that accepts two integer variables in its parameter and defines the if block that checks the prime number condition by the recursive method and returns a value true or false. Inside, the main method an integer variable is declared that uses the Scanner class object for input value and passes into the method and prints its value.

You might be interested in
You are the systems administrator for a scientific research company that employs over 100 scientists who write and run Linux pro
Ber [7]

Answer:

ls, cd, cat, nano, gedit

Explanation:

There are several commands that will help the sys admin navigate through files but the most common ones are ls and cd. The cd command is quite helpful especially if the sys admin wants to change the current working directory. The ls, however, is the go-to command when we want to navigate and list computer files and folders. Typing ls without invoking any arguments will list all the files in the current working directory. He can invoke extra arguments if he wants to like adding an -a and will list entries starting with . To open text files, the sys admin can use cat, nano, or gedit followed by the text file name to view contents in that file.

8 0
3 years ago
Draw any five (5) basic symbols used for flowcharting
Mekhanik [1.2K]

Answer:

Image below ⏬

6 0
3 years ago
What process periodically validates a user’s account, access control, and membership role on inclusion in a specific group?a. Re
Gennadij [26K]

Answer: (A) Recertification

Explanation:

 Recertification is the process that simplify and also automatically re-validate the account of the target type also the member of the resource group. It is the process in which the user account are validated periodically and also control the access.

  • The policies of the re-certification basically initiate the workflow in the activity and also set the accurate notification during the process of re-certification.
  • The re-certification access is important as it enables the companies for reviewing all the external and the internal users.
  • It provide various types of benefits to the organization as it increase the security and also the re-certification accuracy.

Therefore, Option (A) is correct.

6 0
3 years ago
Brianna is taking a backpacking trip in the wilderness and wants to back up the photos from her camera. Which type of storage de
Katen [24]

Answer:

<u><em>C</em></u>

Explanation:

Flash drives usually have an input (E.G. one of those android charger connectors), so just plug that into your camera, and load the flash drive with the photos. Then go home and plug the USB on the flash drive into your PC. If there isn't already, a folder will be made in your "Pictures" folder on your PC, to which you can open the folder, and then your photos should be there. From there you can open them, print them, etc.

Hope this helped, and sorry if I didn't answer in time.

6 0
3 years ago
Which math ratio represents efficiency?
andrew-mc [135]

Answer:

I think its the second one

6 0
3 years ago
Other questions:
  • Which spreadsheet operation does a look function perform?
    5·1 answer
  • java Consider a class MotorBoat that represents motorboats. A motorboat has attributes for: The capacity of the fuel tank The am
    15·1 answer
  • You have a large text file of people. Each person is represented by one line in the text file. The line starts with their ID num
    5·1 answer
  • ¿Qué significa PPO a nivel de programación?
    15·1 answer
  • Write a technical term for following statements
    15·1 answer
  • Determine the number of character comparisons made by the brute-force algorithm in searching for the pattern GANDHI in the text
    7·1 answer
  • How do I make time go by faster?? school is so boring gosh..
    10·2 answers
  • What's the answer plssss​
    10·1 answer
  • Please help please help
    10·1 answer
  • A user may enter some text and the number of times (up to a maximum of 10) to repeat it. Display the text repeated that many tim
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!