Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdint.h>
- using namespace std;
- int main()
- {
- int primes[10000000]; //10m places for primes
- primes[0] = 2;
- primes[1] = 3;
- int number = 2;
- int found = 0;
- int n = 10000000;
- cout << "2, 3, ";
- for (uint64_t i = 5; i < n; i+=2) {
- found = 0;
- for (uint32_t j = 0; j < number; j+=1) {
- if ((i % primes[j]) == 0) {
- found = 1;
- break;
- }
- }
- if (!found) {
- primes[number] = i;
- number += 1;
- cout << i << ", ";
- }
- }
- cout << endl << endl << "Total found prime numbers: " << number;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement