1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <iostream>
using namespace std;
/*Generation of a prime number
by use of the Sieve of Eratosthenes */
int main()
{
int int_list, x;
for(int_list=2; int_list<=100; int_list++)//Print list of intergers between 2 and 100.
cout << int_list << "\n";
cin.ignore();
system("cls");//Restart after displaying integers.
/* I am running the loop a second time, and pairing it with a second loop,
this is with the hope that I can have the program go through each interger
on the list, and then display any integer on that list that is not a multiple
of 2, 3, 5, or 7. I am using the x loop to do (2,3,5,and 7 * 2,3,4,5,6,etc..) */
int_list=2;
for(int_list=2; int_list<=100; int_list++)//loop 1
for(x=2;x<=50;x++)//loop 2
if (int_list != (2*x) || (3* x) || (5*x) || (7*x));
cout << int_list;
cin.ignore();//wait for key press to close program
| |