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
Orlov [11]
4 years ago
13

A prime number is an integer greater than 1 that is evenly divisible by only 1 and itself. For example, the number 5 is prime be

cause it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided by 1, 2, 3, and 6. Write a Boolean function named isPrime, which takes an integer as an argument and returns true if the argument is a prime number, and false otherwise.

Computers and Technology
2 answers:
Natasha_Volkova [10]4 years ago
3 0

Answer:

Since no programming language is stated, python will by used.

Explanation:

def  isPrime():

#first we ask for a number that will be tested

   data= int(input("please enter a number"))

#the next line is where the number will be tested to see if its a prime

   if (data>1):

       if(data % 2)==1:

           print("true")

       else:

           print("False")

   else:

       print("Enter a number greater than 1")

isPrime()

ELEN [110]4 years ago
3 0

Answer:

I am writing a C++ program.    

bool isPrime(int integer)  //boolean function that takes integer argument //and returns true if argument is prime number otherwise false

{  if (integer > 1)  // if the integer value is greater than 1

{   for (int i = 2; i <= integer; ++i)  

//loop starts from 2 and iterates until the value of i gets greater than integer //value

 {  if (integer % i == 0)  // if integer value is completely divisible by i

  {    if(integer == i)  // if integer value is equal to i

    return true;  //function returns true

   else     //if integer value is not divisible by i

    return false;  //function returns false } } } }  }

 

Explanation:

In order to see the output of the program you can write a main() function as following:

int main()  {  //start of the main() function body

int integer;    // int type variable integer

cout<< "Enter an integer:  ";  //prompts user to enter an integer value

 cin  >> integer;   //reads the input from user

cout << integer<<" ";   //prints the integer value entered by user

if (isPrime(integer))  

// calls boolean function to check if the integer value is prime number or not

{   cout << " is a Prime number." << endl;   }

//displays the message number is prime

else  //if the integer value is not prime

 cout << " is not a Prime number." << endl;  }  //displays message

The output along with the program is attached as screenshot.

You might be interested in
Why should we learn Ethereum? Explain.
Licemer1 [7]

Answer:

<h3><em>Ethereum Benefits</em></h3><h3><em>It has a large and committed global community and the largest ecosystem in blockchain and cryptocurrency. Wide range of functions. Besides being used as a digital currency, Ethereum can also process other financial transactions, execute smart contracts and store data for third-party applications.</em></h3>

Explanation:

<h3><em>Hope this helps and mark as a brianliest</em></h3>
7 0
2 years ago
Where will the CPU store data for easy access and quick retrieval during these computations?
zalisa [80]
CPU's have little storage devices on the CPU called registers.
4 0
3 years ago
The school has determined that finding the absolute best schedule cannot be solved in a reasonable time. Instead they have decid
Anettt [7]

Answer:

i dont know what to say

Explanation:

... speechlessss

4 0
3 years ago
Inputs to a system that can enhance performance is called
disa [49]
Inputs to a system that can enhance performance is called Resources
6 0
3 years ago
Read 2 more answers
What two sets of data does every folder and file on an ntfs partition list?
QveST [7]
Read and execute are the two sets of data
8 0
3 years ago
Other questions:
  • (The Location class) Design a class named Location for locating a maximal value and its location in a two-dimensional array. The
    10·1 answer
  • What parts of the computer does it not need to function?​
    9·1 answer
  • Megan has written the following rough draft for her assignment. Choose the correct way to complete each sentence. Sarah is creat
    13·1 answer
  • Read the excerpt from The Code Book. Other attacks include the use of viruses and Trojan horses. Eve might design a virus that i
    13·1 answer
  • An audit trail is a record of how a transaction was handled from input through processing and output
    10·1 answer
  • Ayudaaaaa, Instale el software equivocado a mi tv westinghause con placa tp.Ms338.Pb801 y ahora queda en negro, ¿Cómo lo puedo s
    15·1 answer
  • 8.10.8 guess the passcode codehs
    8·1 answer
  • Does anyone know what's wrong with this code in Unity? HELP FAST PLEASE! This is for my game design course, I will give brainies
    11·1 answer
  • Briefly explain how human thinking is mapped to artificial intelligence components
    5·1 answer
  • The ________ encloses and protects the power supply, motherboard, processor, and memory of a computer. drive bay solid-state sto
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!