【Project Euler】7 第七题

2015/09/08 21:48
阅读数 12


//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);
                }
            }
        }

版权声明:本文为 NoMasp柯于旺 原创文章,未经许可严禁转载!欢迎访问我的博客:http://blog.csdn.net/nomasp

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部