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
AysviL [449]
3 years ago
15

Assume the availability of a function is_prime. Assume a variable n has been associated with positive integer. Write the stateme

nts needed to find out how many prime numbers (starting with 2 and going in increasing order with successively higher primes [2,3,5,7,11,13,...]) can be added before exceeding n. Associate this number with the variable k.
Computers and Technology
1 answer:
vivado [14]3 years ago
6 0

Answer:

def main():

   n = int(input('Enter the value of the variable n:'))

   k=2;

   totalSum = 0

   print('The list of the prime numbers are as follows:')

   while k <= n:

       totalSum = totalSum+is_prime(k)

       k=k+1

   print('Total sum of the prime numbers:',totalSum)

def is_prime(k):

   primeNumber = 0      

   i=1

   while i<=int(k):

       if (k % i) == 0:

           primeNumber = primeNumber + 1

       i=i+1

   if(primeNumber==2):      

       print(k)

       return k;

   else:        

       return 0;

main()

Explanation:

  • Run the while loop until k is less than n.
  • Determine if the variable k is prime then add it to the totalSum variable.
  • Increment the value of k by 1.
  • Create a function isPrime to check whether the number is prime  or not by determining the factors of k which can be found using the modulus operator.
  • Call the main function at the end.

You might be interested in
What folder in windows is intended to be used for folders and files that all users of a computer share?
andrew11 [14]
The <span>Public folder is meant to be used by all users.</span>
4 0
4 years ago
When two files are linked together, the __________ file receives the data from another workbook.?
Ket [755]
When two files are linked together, the <u>d</u><span><u>estination </u></span>file receives the data from another workbook.

If i'm not wrong.

3 0
3 years ago
Mha ship what yo fave
Diano4ka-milaya [45]

Answer:

umm the first one I think..? lol

4 0
3 years ago
Read 2 more answers
An operations information system typically accesses data gathered by a _____ system and converts the data into useful informatio
Darina [25.2K]
Answer: Operating System 
6 0
3 years ago
What is two features of the minicomputer?​
Vesnalui [34]

Answer:

It is smaller in size than a mainframe computer. It is less expensive than a super and mainframe computer. It is not much more powerful than the mainframe and supercomputer, but powerful than microcomputers. It supports multiprocessing and multi-tasking.

Explanation:

4 0
3 years ago
Other questions:
  • Using physical proximity to gain login information, passwords, or other personal information is known as a(n) ____.
    7·1 answer
  • Discuss the software development methodology you would use for developing a software product for insurance agents, and state val
    10·1 answer
  • _____ is a touch screen that is up to four feet by six feet.
    14·2 answers
  • How do I report a user? (https://brainly.com/profile/TheBrainHelper-20043487)
    9·2 answers
  • Dir, attrib, cd, and rem are all examples of:
    11·2 answers
  • A file is to be shared among different processes, each of which has a unique number. The file can beaccessed simultaneously by s
    13·1 answer
  • Which protocol sends a request to view or download a website or file ​
    7·1 answer
  • An internet layer is a quantity of data that is transmitted on a netowrk without concern for whether it is accurate or whether i
    5·1 answer
  • If you want to transfer information transform STM to LTM, it is essential that you make the information ______________________.
    9·1 answer
  • The hardware and software that must be implemented to support the applications that the primary activities use are a part of the
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!