/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mypkg;import java.math.*;/**
*
* @author XiaoG
*/
public class Main { /**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int count = 0;
for (int i = 2; count <= 100; i++) {
if (isPrime(i)) {
count++;
if ((count % 10)!=0) {
System.out.println(i + " ");
} else {
System.out.println('\n' + i + " ");
}
}
}
} public static boolean isPrime(int num) {
for (int i = 2; i <= Math.sqrt(num); i++) {
if ((num % i)==0) {
return false;
}
}
return true;
}
}
请问,我这段代码在netbeans怎么不能正常运行啊?
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mypkg;import java.math.*;/**
*
* @author XiaoG
*/
public class Main { /**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int count = 0;
for (int i = 2; count <= 100; i++) {
if (isPrime(i)) {
count++;
if ((count % 10)!=0) {
System.out.println(i + " ");
} else {
System.out.println('\n' + i + " ");
}
}
}
} public static boolean isPrime(int num) {
for (int i = 2; i <= Math.sqrt(num); i++) {
if ((num % i)==0) {
return false;
}
}
return true;
}
}
请问,我这段代码在netbeans怎么不能正常运行啊?
解决方案 »
- java gui的问题double型的画图
- 急!!文件目录重命名问题
- Java 实现 一个输入输出类 和febonacci数列
- 在线求:能不能在 一个类里面写一个方法,这个方法,每隔一段事件(时间可设定)自动访问数据库,并将数据读出来?
- 诡异的StringBuffer!!!!!!!!
- 送分题!!!!!!!!!!!!!!!!!!!!!快!!!!!!!抢分啊!!!!!!!!!
- 急!(高分求助!)请问如何实现文件传输?(最好有源码)
- 关于思想与语言的问题,求大神们给解答!!!!
- 怎么把.java文件编译成可执行文件
- 怎么开始学习JAVA,没有c++的基础,很困惑
- 关于mark(int readlimit)的参数readlimit
- 如何在Vector中存放数据类型?
你的出错吗?把错误也贴出来吧
2
3
5
7
11
13
17
19
23
39
31
37
41
43
47
53
59
61
67
81
73
79
83
89
97
101
103
107
109
123
127
131
137
139
149
151
157
163
167
183
179
181
191
193
197
199
211
223
227
239
233
239
241
251
257
263
269
271
277
291
283
293
307
311
313
317
331
337
347
359
353
359
367
373
379
383
389
397
401
419
419
421
431
433
439
443
449
457
461
473
467
479
487
491
499
503
509
521
523
551
547
你应该先编译,然后将编译后的文件放入包中,再在命令提示符中运行是应该是 Java 包名.javaname(Main)