public static long sum7()
{
int c = 1;
boolean isprime = true;
long prime = 0;
for (long i = 3; i <= Long.MAX_VALUE; i++)
{
for (long j = 2; j < i; j++)
{
if (i % j == 0)
{
isprime = false;
break;
}
}
if (isprime == true)
{
c++;
}
if (c == 10001)
{
prime = i;
break;
}
}
return prime;
}
static Scanner scanner1 = new Scanner(System.in);
public static void main(String[] args)
{
System.out.println(sum7());
}
我正在为项目欧拉问题(Q7)尝试以下代码,我应该找到第 10001 个素数,但它只是不起作用。构建成功,但没有显示任何内容请帮助。提前致谢....