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]
4 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]4 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 you open as many links as you want, and still stay in the same browser window instead of cluttering your screen with multip
emmainna [20.7K]

Answer:

a. Tabbed browsing

Explanation:

Tabbed browsing is a feature in the browser that helps in operating several tabs at the same time. It helps in browsing different links without opening different browsers. Multiple pages can be opened and surfed at the same time in one window. Any link can be opened in a different or new tab by clicking right on the link. After this, 'open link in new tab' is to be selected and the link gets opened respectively.

3 0
3 years ago
Identify a characteristic of electronic meeting systems.
densk [106]

Answer:

The correct answer to the following question is an option (b).

Explanation:

Desktop conferencing is the feature of the electronic meeting system.

An EMS or electronic meeting system is an application that gives us the facilities of problem-solving and making decisions for that problem within a group, and it also provides the best feature of web conferencing, and the desktop conferencing by which we can chat and tells our problem in the group or a person.

8 0
3 years ago
Then create a new Java application called "StringSlicer" (without the quotation marks) that uses methods to:
anyanavicka [17]

Answer:

See the explanation section

Explanation:

import java.util.*;

//The above statement is to import the Scanner and ArrayList class

public class StringSlicer {

   public static void main(String args[]) {

   Scanner scan = new Scanner(System.in);

   System.out.println("Enter your string: ");

   String inputString = scan.nextLine();

   

   ArrayList<Character> stringList = new ArrayList<Character>();

   for(int i = 0; i < inputString.length(); i++){

           stringList.add(inputString.charAt(i));

       }

       

   for(Character letter: stringList){

           System.out.println(letter);

       }

   }

}

5 0
4 years ago
) Suppose algorithm A takes 10 seconds to handle a data set of 1000 records. Suppose the algorithm A is of complexity O(n2). Ans
Mice21 [21]

Answer:

i) The time taken for 1500 records = 15 seconds.

ii) The time taken for 1500 records = 50 seconds.

Explanation:

A is an O(n) algorithm.

An algorithm with O(n) efficiency is described as a linearly increasing algorithm, this mean that the rate at which the input increases is linear to the time needed to compute that algorithm with n inputs.

From the question, it is given that for 1000 records, the time required is: 10 seconds.

Algorithm time taken is O(n)

Hence,

1) For 1,500 records

=> 10/1000 = x/1500

=> 10x1500/1000 = x

x = 15 seconds

Thus, the time taken for 1500 records = 15 seconds.

2) For 5,000 records

=> 10/1000 = x/5000

=> 10x5000/1000 = x

x = 50 seconds

Thus, the time taken for 1500 records = 50 seconds.

8 0
3 years ago
True or false, cloud storage does not require internet access?
Dmitry_Shevchenko [17]
False, the storage is being accessed from the cloud which can only be accessed through an internet connection.
3 0
4 years ago
Other questions:
  • Are sql injections legal?
    15·1 answer
  • Evaluate the following expressions.
    10·1 answer
  • Anyone willing to help with Excel?!!
    15·1 answer
  • Object Oriented Programming (OOP) allows us to handle complex code in an organized structure and break down the problem by model
    5·1 answer
  • Which tab on the ribbon houses the sort functions?<br><br> Insert<br> Data<br> View<br> Home
    11·1 answer
  • Part 1: 1) Write a C program getPhoneNumber.c that accepts a phone number from the user in the form XXX-XXX-XXXX, and then displ
    12·1 answer
  • Write and application that reads five integers from the user and determines and prints the largest and the smallest integers. Us
    7·1 answer
  • PLZZZ HELP!!!
    9·1 answer
  • Activity 8. Direction: Read the article and make an outline. Be guided by the rubric for outlining. Write your answer on a separ
    15·1 answer
  • Is this statement true or false? While in slide show mode, if you are not careful you can close the application by clicking the
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!