?? findprimes.java
字號(hào):
public class FindPrimes
{
public static void main(String[] args)
{
int nPrimes = 50; // The maximum number of primes required
// Check all values from 2 to nValues
OuterLoop:
for(int i = 2; ; i++) // This loop runs forever
{
// Try dividing by all integers from 2 to i-1
for(int j = 2; j < i; j++)
{
if(i % j == 0) // This is true if j divides exactly
continue OuterLoop; // so exit the loop
}
// We only get here if we have a prime
System.out.println(i); // so output the value
if(--nPrimes == 0) // Decrement the prime count
break OuterLoop; // It is zero so we have them all
}
// break OuterLoop goes to here
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -