1. 程式人生 > >1~100內所有素數的和

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");
				}
			}
		}
	}
}