[ create a new paste ] login | about

Link: http://codepad.org/2oWQIQD3    [ raw code | output | fork ]

C++, pasted on Jan 18:
#include <iostream>

using namespace std;

int main()
{
    int prime = 0;
    int a=0;
    int b=1;
    int c=0;
    for (int i = 2; i<20000000; i++)
    {
        if (a!=10001)
        {
            if (i >= 900)
            {
                c=1;
                b=1;
            }
            if (i <= 900)
            {
                c=0;
                b=1;
            }

            while ((b <= 900) && (c < 3))
            {
                if (i %b == 0)
                {
                    c++;
                }
                if ((b >= 900))
                {
                    a++;
                    //cout << "Prime Number: #" << a << " : " << i << endl;
                    b=901;
                }
                if (b < 900)
                {
                    b++;
                }
            }
        }
        if (a==10001)
        {
            prime=i;
            break;
        }
    }

    cout << prime << " is the 10001 prime number." << endl;
    return 0;
}


Output:
1
104743 is the 10001 prime number.


Create a new paste based on this one


Comments: