JAVA basic programming exercises-2

Problem: Determine how many prime numbers are between 101-200 and output all prime numbers.

Prime numbers are also called prime numbers. Except for 1 and itself, no integer is divisible by it. That is, prime numbers have only two factors.

public class example1 {
	public static void main(String[] args) {
		biaohao:
		for(int i=101;i<=200;i++) {
			int temp=i;
			for(int j=2;j<=Math.sqrt(temp);j++) {
				if(temp%j==0) {
					continue biaohao;
				}
			}
			System.out.println(temp);
		}
	}
}

Guess you like

Origin blog.csdn.net/Warmmm/article/details/107545351