参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); for(int i = 2; i <= n; i++) if(judge(i)) System.out.println(i); } public static boolean judge(int x) { for(int i = 2; i * i <= x; i++) if(x % i == 0) return false; return true; } }
0.0分
6 人评分
数组与指针的问题浏览:718 |
C二级辅导-计负均正 (C语言代码)浏览:482 |
C二级辅导-阶乘数列 (C语言代码)浏览:521 |
时间转换 (C语言代码)浏览:627 |
计算质因子 (C语言代码)浏览:707 |
简单的a+b (C语言代码)浏览:416 |
C二级辅导-统计字符 (C语言代码)浏览:647 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:560 |
买不到的数目 (C语言代码)浏览:3094 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:817 |