Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Project Prime Numbers. wnte a peagram that reads in an antear that greate than 2

ID: 3796149 • Letter: P

Question

Project Prime Numbers. wnte a peagram that reads in an antear that greate than 20et's and nnds and pnnts all of the prime numbersbetwreo 3 and A prime number suchthat 1 are the only numbers that evenly svideit (for example 13, 17 ay to solve tisproeiem is to use doubly nested loop The outer loop can itetate rrom 3 to whee the inner loop checks to see f the courteen yslue for the outer Moop s prime. One way to see from these numbers everly drvides then cannot be prime. none of the Yahuts frem 2 to everly divides in, then a must be prime. (Note that there we several easy ways to make ths agorithm

Explanation / Answer

#include <iostream>
using namespace std;

int main() {
   int k;
   cout<<" enter the size of array:";
   cin>>k;
  
   for (int i=0;i<k;i++)
   {
   for(int j=2;j<i;j++)
   {
   if (i % j == 0){break;}
else if (i == j+1){
cout << i << " ";}
   }
   }
  
   return 0;
}