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
Aliun [14]
2 years ago
14

Create a function named test2Problem2that contains a list comprehension. This function will take asingle integer parameter nand

returns a list of length n of every other prime. (Please note that primes start at 2.)There will be a 10 point deduction for not using a list comprehension to solve this problem.List comprehensions have this form: [ expression for item in list if conditional ]In:10Out:[2,5,11,17,23,31,41,47,59,67]In:7Out:[2,5,11,17,23,31,41]
Computers and Technology
1 answer:
ikadub [295]2 years ago
3 0

Answer:

C++.

Explanation:

#include <iostream>

using namespace std;

/////////////////////////////////////////////////////////

void printPrime(int n) {

   if (n > 0) {

       cout<<"[2";

       for (int i=3; i<=n; i++) {

           bool isPrime = true;

           

           for (int j=2; j<i; j++) {

               if (i % j == 0) {

                   isPrime = false;

                   break;

               }

           }

           

           if (isPrime == true)

               cout<<", "<<i;

       }

   }

   else {

       cout<<"Invalid input";

   }

   cout<<"]";

}

/////////////////////////////////////////////////////////

int main() {

   int n;

   cout<<"Enter positive integer: ";

   cin>>n;

   printPrime(n);

   return 0;

}

You might be interested in
Given a computer running four types of instuctions, named classes A through D, calculate the execution time of a program that ha
My name is Ann [436]

Answer:

IT B

Explanation:

3 0
2 years ago
Fill in the blank with the correct term.
frozen [14]
Its bubble sort!!! Thats my final answer! Youre welcome
8 0
2 years ago
Read 2 more answers
2. ¿Cuáles de los siguientes Software son lenguajes de Programación?
poizon [28]

B) C# Java y Visual Basic

6 0
3 years ago
Please help me excel questions!​
Elenna [48]

Answer:

hi,hi,hi,hi,hi,hi,hi,hi,hi,hi,hi,hi,hi

7 0
2 years ago
Read 2 more answers
A Uniform Resource Locator (URL) consists of three separate parts: network protocol, host, and web browser.
FrozenT [24]
That is false. are you doing it on a computer course.                                             <span />
3 0
3 years ago
Read 2 more answers
Other questions:
  • ll of the following are extra precautions you can take to secure a wireless network EXCEPT ________. Select one: A. turn on secu
    9·1 answer
  • Litmus-type test strips are used to test coolant for freeze protection and ?
    12·1 answer
  • Under which menu option of a word processing program does a star appear
    8·1 answer
  • Why is a networked system a benefit?
    7·1 answer
  • State all the generations of computers.
    10·2 answers
  • What is a Hard Drive
    13·1 answer
  • 2.8 Code Practice: Question 2
    11·1 answer
  • In this section of your final project, you will write a basic script to create and back up files. You will create this script wi
    11·2 answers
  • IN WHICH COUNTRY DO THEY LET YOU PLAY MINECRAFT IN SCHOOL?
    8·2 answers
  • Select the correct answer.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!