- public class Test {
- public static void main(String[] args) {
- getNum();
- }
- private static void getNum() {
- for (int i = 1; i <= 100; i++) {
- boolean flag = true;
- for (int j = 2; j < i; j++) {
- if(i%j == 0){
- flag = false;
- break;
- }
- }
- if(flag){
- System.out.print(i+",");
- }
- }
- }
- }
复制代码 |
|