标签:rgs div ber for new ack [] stat int
代码如下:
package day06;
public class TestSU {
public static void main(String[] args) {
StackOfIntegers stkInt = new StackOfIntegers();
for(int i = 2; i < 300; i++) {
if(isPrime(i)) {
stkInt.push(i);
}
}
while (!stkInt.isEmpty()) {
System.out.print(stkInt.pop() + " ");
}
}
/**
* 判断一个数是否为素数
* @param number
* @return
*/
private static boolean isPrime(int number) {
for (int divisor = 2; divisor <= number / 2; divisor ++) {
if (number % divisor == 0) {
return false;
}
}
return true;
}
}
标签:rgs div ber for new ack [] stat int
原文地址:http://www.cnblogs.com/F001li/p/7055876.html