//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.youkuaiyun.com/nomasp
本文介绍了一种通过编程方式寻找特定位置素数的方法,展示了如何使用C#语言实现对大量数字进行素性判断的过程,最终找出第10001个素数。
2372

被折叠的 条评论
为什么被折叠?



