天天看點

【Project Euler】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?

static void main(string[] args)

        {

            int count = 0;

            for (int i = 3; i < 1000000; i++)

            {

                int index = -1;

                for (int j = 2; j < i; j++)

                {

                    if (i % j != 0 && i != j)

                    {

                    }

                    else

                        index += 1;

                }

                if (index == -1)

                    //console.writeline(i);

                    count += 1;

                if(count==10000)

                    console.writeline(i);

            }

        }

繼續閱讀