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
What software can be used for remote operation of a sunsdr2 dx?.
Rasek [7]

Answer:

Install the ExpertSDR2 Remote Client software on your PC. Download the client here. You can also access your device via any web browser

8 0
2 years ago
In mathematics, "quadrant I" of the cartesian plane is the part of the plane where x and y are both positive. Given a variable,
lbvjy [14]

Answer:

#include <iostream>

using namespace std;

struct Cartesian {

double x;

double y;

};

int main() {

// creating a pointer p of type struct Cartesian

struct Cartesian *p = new Cartesian ;

cout << " Enter x: ";

// accessing the structure variable x by arrow "->"

cin >> p->x;

cout << "Enter y: ";

// accessing the structure variable y by arrow "->"

cin >> p->y;

// expression to check whether x and y lie in Quadrant 1

if (p->x > 0 && p->y > 0) {

 cout << "X and Y are in Quadrant 1 ";

}

else

{

 cout << "x And y are not in Quadrant 1";

}

// deleting the struct pointer p

delete p;

return 0;

}

Explanation:

in order to locate memory in heap, keyword "new" is used in C++ so,

struct Cartesian *p = new Cartesian ;

in order to access data members of the structure using pointer we always use an arrow "->". otherwise a dot oprerator is used to access data members.

in order to check whether x and y lie in 1st quadrent, we must use && operator in our if condition. so

if (p->x > 0 && p->y > 0)

&& will return true iff x and y both are +ve.

deleting the struct pointer p is important beacuse we are allocating memory in heap so heap memory should be used a resource and must be release when not needed otherwise it can cause memory leakage problems. so  

delete p;

5 0
3 years ago
Putting commands in correct order so computers can read the commands
lana66690 [7]

Answer:

its b I think I'm pretty sure

8 0
2 years ago
The ip address 221.1.10.53 /24 is a what type of address?
jekas [21]
It is a class C address.  Class C covers all addresses in the range 192.0.0.0 to 223.0.0.0.  The /24 represents the number of network bits in the address so we can work out that the subnet mask of this address would be 255.255.255.0.
8 0
3 years ago
If you want to copy data from one cel to another cell that is several rows down in a worksheet, which method should you use?
bogdanovich [222]

copy and paste

so you can keep the data in the current cell and add it to other cells that you want that data in as well

5 0
3 years ago
Other questions:
  • .The process of capturing the requirements includes all ofthe following with the exception of:
    10·1 answer
  • Which group of commands all appear on the Standard toolbar?
    9·2 answers
  • Write a program to generate personalized junk mail. The program takes input both from an input file and from the keyboard.The in
    14·1 answer
  • A binary message consisting of four bits was sent to you by a friend. The message was supposed to be ABAB. Unfortunately, your f
    8·1 answer
  • As a prospective student, what is the best reason to request an interview with your college application?
    6·1 answer
  • Is the most important characteristic of a hard drive.​
    7·2 answers
  • Imagine that a team of scientists test a certain hypothesis, and the experimental results show that it is false.
    6·1 answer
  • Read the attached paper titled A Survey of Coarse-Grained Reconfigurable Architecture and comment on it. Make sure to specifical
    5·1 answer
  • Suggest three ways in which celebrating an occasion influences food choices?
    10·2 answers
  • To make the monster pace, you needed the monster to turn ___ degrees.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!