[ create a new paste ] login | about

Link: http://codepad.org/8BinJUWR    [ raw code | fork ]

C++, pasted on Dec 14:
#define n 200000
#include <iostream>
using namespace std;

int main()
{
    int p[n];
    p[0] = 2;
    int idx = 1;
    int i;
    for (i = 1; i < n; i++) p[i] = 0;
    for (i = 3; i < n; i++)
    {
        bool bp = true;
        for (int j = 0; j < idx; j++)
        {
            if (i % p[j] == 0) { bp = false; break; }
        }
        if (bp) p[idx++] = i;
    }
    i = 0;
    // while (p[i] != 0) cout << p[i++] << endl;
}


Output:
No errors or program output.


Create a new paste based on this one


Comments: