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
natima [27]
3 years ago
12

Write a function isPrime of type int -> bool that returns true if and only if its integer parameter is a prime number. Your f

unction need not behave well if the parameter is negative.

Computers and Technology
1 answer:
PolarNik [594]3 years ago
5 0

Answer:

import math

def isPrime(num):

 

   if num % 2 == 0 and num > 2:

       return False

   for i in range(3, int(math.sqrt(num)) + 1, 2):

       if num % i == 0:

           return False

   return True

Explanation:

The solution is provided in the python programming language, firstly the math class is imported so we can use the square root method. The first if statement checks if the number is even and greater than 2 and returns False since all even numbers except two are not prime numbers.

Then using a for loop on a range (3, int(math.sqrt(num)) + 1, 2), the checks if the number evenly divides through i and returns False otherwise it returns True

see code and output attached

You might be interested in
When the binary code is retrieved from ram and moved to the cpu, this stage is known as
vaieri [72.5K]

This stage is known as fetching.

  • Any operation you do in a computer, it runs a lot of codes inside it, and these codes are in binary.
  • For the operation, the computer accesses the RAM memory to gather information about this process, and moves it to the CPU, in a process named as fetching.
  • Thus, the stage asked in this problem is known as fetching.

A similar problem is given at brainly.com/question/21536104

4 0
3 years ago
What is an insertion point?
Tasya [4]
The answer to that would have to be c I think this is it so a feature bl bl bla
7 0
3 years ago
Hello everyone. I need help. C programming. Create at least two more functions except the main () function to collect them.
Andrew [12]

Answer:

Explanation:

#include <iostream>

using namespace std;

int costdays(int);

int costhrs(int,int);

int main()

{

   int dd,hh,mm,tmph,tmpd,tmpm=0;

   int pcost,mcost=0;

   cout<<"Enter Parking time" << endl;

   cout<<"Hours: ";

   cin>>hh;

   cout<<"Minutes: ";

   cin>>mm;

   

   if (mm>60)

   {

       tmph=mm/60;

       hh+=tmph;

       mm-=(tmph*60);

   }

   if (hh>24)

   {

       tmpd=hh/24;

       dd+=tmpd;

       hh-=(tmpd*24);

   }

   if ((hh>4)&&(mm>0))

   {

       pcost+=costdays(1);

   }

   else

   {

       mcost=costhrs(hh,mm);

   }

   cout<<"Total time: ";

   if (dd>0)

   {

       cout<<dd<<"days ";

       pcost+=costdays(dd);

   }

   pcost+=mcost;

   cout<<hh<<"h "<<mm<<"mins"<<endl;

   cout<<"Total Cost :"<<pcost<<"Won";

   return 0;

}

int costdays(int dd)

{

   return(dd*25000);

}

int costhrs(int hh,int mm)

{

   int tmpm, tmp=0;

   tmp=(hh*6)*1000;

   tmp+=(mm/10)*1000;

   tmpm=mm-((mm/10)*10);

   if (tmpm>0)

   {

       tmp+=1000;

   }

   return(tmp);

}

3 0
3 years ago
How many digits are in the binary number system? Explain why.
Katen [24]

Answer:

Since there are only two digits in binary, there are only two possible outcomes of each partial multiplication: If the digit in B is 0, the partial product is also 0. If the digit in B is 1, the partial product is equal to A.

Explanation:

8 0
3 years ago
Read 2 more answers
In the wireless telecommunications industry, different technical standards are found in different parts of the world. A technica
Serhud [2]

Answer:

A varying infrastructure.

Explanation:

The competitive pressure it creates for multinational companies in the industry is one of difference in infrastructure because different technical standards are found in different parts of the world.

For instance, A technical standard known as Global Systems for Mobile (GSM) is common in Europe, and an alternative standard, Code Division Multiple Access (CDMA), is more common in the United States and parts of Asia.

Consequently, equipment designed for GSM will not work on a CDMA network and vice versa as a result of varying infrastructure, so companies would be innovative in order to improve on their products.

3 0
3 years ago
Other questions:
  • What is the 7 X 7 when referring to PowerPoint presentations?
    12·2 answers
  • Analog signals consists of individual electric pulses that represents bits group together into bytes {True/False}
    13·1 answer
  • Traffic that is encrypted will typically pass by an intrusion prevention system untouched.a. Trueb. False
    10·1 answer
  • Which method can help you prevent RSI while using a keyboard?
    14·1 answer
  • Professionalism is defined as what?<br> ASAP PLEASE!
    11·1 answer
  • _____ is a program that allows a person using one computer to access files and run programs on a second computer that is connect
    11·1 answer
  • How do you get the computer to stop opening randomly
    15·2 answers
  • Credible sites contain __________ information,
    7·2 answers
  • In java please
    13·1 answer
  • Hi, I am from India. Our brainly platform isn't so good, many of 'em keep spamming questions that I ask. US platform seems much
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!