Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Project Euler("https://projecteuler.net/archives")
- Problem 7
- By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
- What is the 10 001st prime number?
- */
- int main(){
- long long num = 1000000, exist = 0;
- bool primeFactor = true;
- for (long long i = 2; i < num; i++){
- for(long long j = 1; j < i; j++){
- if( j != 1 && i%j == 0) primeFactor = false;
- }
- if(primeFactor == true){
- exist++;
- if(exist == 10001) cout << i << endl;
- }
- primeFactor = true;
- }
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment