java代码输出1到100的质数

总结:循环,循环。。

package com.dfd;

import java.util.Scanner;

//输出0到100的质数
//要判断当到100时候,等于2的直接输出,能被2整除的不输出,
//其他的不能被2整除的,请输出。】
//三个内容,如何同时综合输出。

public class tyr {
	public static void main(String[] args) {
		Scanner c = new Scanner(System.in);
		// System.out.println("请输次数----");
		// int x=c.nextInt();
		// int y=2;
		// int z=c.nextInt();
		for (int i = 0; i < 100; i++) {
			if (i == 2) {
				System.out.println("" + i);
			} else if (i % 2 != 0) {
				System.out.println("" + i);
			}

		}
	}
}
//
1
2
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
51
53
55
57
59
61
63
65
67
69
71
73
75
77
79
81
83
85
87
89
91
93
95
97
99

  

原文地址:https://www.cnblogs.com/langlove/p/3409733.html