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
Carlos, an algebra teacher, is creating a series of PowerPoint presentations to use during class lectures. After writing, format
yarga [219]

Answer:

see explanation

Explanation:

Carlos can make a copy of the old presentation that preserves all the formatting, and replace old content with new information.

5 0
3 years ago
How many degrees of freedom does any unconstrained object have in 3-D modeling?
Free_Kalibri [48]
I think its 6 degrees

3 0
3 years ago
How do you draw first angle of orthographic projection ​
attashe74 [19]
Https://technologystudent.com/designpro/ortho1.htm
5 0
3 years ago
Which branch of science helps avoid or minimize stress-related injuries at workplace
dybincka [34]

The answer is : Ergonomics .   It is about ensuring that the work system is favorable to good performance and work effectiveness and consequently,  that the work environment is compatible with the health, safety and comfort of the worker.  It reduces hazards in the working environment.

8 0
3 years ago
A man travel 200m towards east&lt;br /&gt;from his house then takes left&lt;br /&gt;to turn and moves 200 m north&lt;br /&gt;fin
11Alexandr11 [23.1K]
Using the Pythagorean theorem:

200^2 + 200^2 = x^2

x = 282.842712... from the original distance
4 0
3 years ago
Other questions:
  • To change the background color of a page, which tab would you use?
    15·2 answers
  • Write a program that allows the user to convert a temperature given in degrees from either Celsius to Fahrenheit or Fahrenheit t
    13·1 answer
  • Write a complete program to read two integers and display the number of integers that lie between them, including the integers t
    12·1 answer
  • Which of the following is true? Group of answer choices worst case time of Heapsort is better than worst cast time of Quicksort
    10·1 answer
  • According to the video, some workers who work for themselves, such as Actors, Musicians, or Writers, may have what sort of worke
    7·1 answer
  • What's the inputs and outputs in a kitchen?
    14·1 answer
  • Question 1. (50 points) 1.Write a program that computes information related to a sequence of entries regarding age of customers.
    6·1 answer
  • You are configuring a firewall to use NAT. In the configuration, you map a private IP address directly to a persistent public IP
    9·1 answer
  • Any anime weebs wanna talk
    7·2 answers
  • The database cannot be migrated to a different engine because sql server features are used in the application’s net code. The co
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!