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]
2 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]2 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
In Python Calculate the BMI of a person using the formula BMI = ( Weight in Pounds / ( ( Height in inches ) x ( Height in inches
makvit [3.9K]

Answer:

weight_pounds=float(input("Enter the weight in pounds:\n"))#taking input of weight.

height_inches=float(input("Enter the height in inches:\n"))#taking input of thye height.

bmi=(weight_pounds/(height_inches**2))*703#calculating the bmi.

print('The body mass index is '+str(bmi))#printing the result.

Ouput:-

Enter the weight in pounds:

207.8

Enter the height in inches :

72

The body mass index is 28.163395061728398

Explanation:

The above written program is in python.First I have taken input from the user of the weight in pounds then taking input of the height in inches.Then calculating the bmi and storing it in the variable bmi.Then printing the bmi in the end.

6 0
3 years ago
BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLIEST BRAINLI
olganol [36]

Answer:

I think the answer is network

hope this helps

have a good day :)

Explanation:

7 0
3 years ago
Read 2 more answers
Define a method calcPyramidVolume with double data type parameters baseLength, baseWidth, and pyramidHeight, that returns as a d
enyata [817]

Answer:

The method in C++ is as follows:

double calcPyramidVolume(double baseLength, double baseWidth, double pyramidHeight){

   double baseArea = calcBaseArea(baseLength, baseWidth);

   double volume = baseArea * pyramidHeight;

   return volume;    

}

Explanation:

This defines the calcPyramidVolume method

double calcPyramidVolume(double baseLength, double baseWidth, double pyramidHeight){

This calls the calcBaseArea method to calculate the base area of the pyramid

   double baseArea = calcBaseArea(baseLength, baseWidth);

This calculates the volume

   double volume = baseArea * pyramidHeight;

This returns the volume

   return volume;  

}

<em>See attachment for complete program that include all methods that is required for the program to function.</em>

5 0
2 years ago
I’m joining the robotics team in my school, but my knowledge is pretty basic. What should I do to improve myself?
Aleonysh [2.5K]
Start learning the functions of a computer and really put ur heart into it
8 0
3 years ago
The prepaid tuition plan covers
rusak2 [61]
Hey there!

A prepaid tuition plan is a plan that allows you to pay the current rate of tuition now (say, years in advance), even if it's much higher than the time when the payment for tuition would actually be paid. This plan is great for anyone who wants to pay a lower price for high–cost education now (even if their kid isn't college age yet) and not have to worry about economic standing or inflation in the future that could drive the tuition prices up. 

The plan only covers tuition and other similar fees. You can not purchase books or room and board with it in advance. So, your answer should be: C. Tuition and Fees. 

Hope this helped you out! :-)
8 0
3 years ago
Read 2 more answers
Other questions:
  • When might it be necessary or advisable to write a shell script instead of a shell function? give as many reasons as you can thi
    15·1 answer
  • Under extreme programming, ________ and ________ are intimately related parts of the same process
    13·2 answers
  • Your project must satisfy the following requirements:
    7·1 answer
  • If you want to copy text formatting from one area of your document to another area, _____.
    5·2 answers
  • Meaning of page break​
    8·1 answer
  • During the Cold War, defense contractors were required to shield sensitive computing systems and prevent electronic eavesdroppin
    14·1 answer
  • What is the output after running the following code snippet? int number = 600; if (number &lt; 200) { System.out.println("Low sp
    15·1 answer
  • HURRY
    8·1 answer
  • A. What is MS-Word ? Write its uses.
    14·2 answers
  • Using existing algorithms as building blocks for new algorithms has all the following benefits EXCEPT
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!