1~100内所有素数的和

//1~100内所有素数的和
public class Exercise3 {
	public static void main(String[] args) {
		int i,j;
		int hh=0;
		for (i=1;i<=100;i++) {
			for (j=2;j<i;j++) {
				if (i%j==0) {
					break;
				}
			}
			if(i==j) {
				System.out.print(i+"\t");
				hh=hh+1;
				if (hh%5==0) {
					System.out.print("\n");
				}
			}
		}
	}
}

猜你喜欢

转载自blog.csdn.net/qq_31395031/article/details/79744882