-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem7.cpp
More file actions
executable file
·110 lines (75 loc) · 1.24 KB
/
Problem7.cpp
File metadata and controls
executable file
·110 lines (75 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* Problem7.cpp
*
* Created on: Dec 1, 2014
* Author: explicitname
*/
#include <iostream>
#include <vector>
using namespace std;
<<<<<<< HEAD
bool isPrime(int num)
{
bool prime;
=======
bool isPrime(int num)
{
>>>>>>> 389110ad561ba0c76777edee3fd5326b76ffc3c7
for (int i = 2; i < num; i++)
{
if (num % i == 0)
{
i = num;
<<<<<<< HEAD
prime = true;
} else
{
prime = false;
}
}
return prime;
=======
return true;
}
else
{
return false;
}
}
>>>>>>> 389110ad561ba0c76777edee3fd5326b76ffc3c7
}
int main()
{
<<<<<<< HEAD
int maxPrime = 10000;//Max desired prime number
int num = 2;
vector<int> primeVect;
=======
int maxPrime = 10; //Max desired prime number
int num = 2;
vector <int> primeVect;
>>>>>>> 389110ad561ba0c76777edee3fd5326b76ffc3c7
while (primeVect.size() < maxPrime + 1)
{
if (!isPrime(num))
{
<<<<<<< HEAD
cout << num << " :::: " << endl;
primeVect.push_back(num);
}
num++;
=======
primeVect.push_back(num);
}
cout << "..." << primeVect.size() << endl;
num++;
>>>>>>> 389110ad561ba0c76777edee3fd5326b76ffc3c7
}
cout << primeVect[maxPrime] << endl;
<<<<<<< HEAD
return 0;
}
=======
return 0;
}
>>>>>>> 389110ad561ba0c76777edee3fd5326b76ffc3c7