判断 101-200 之间有多少个素数,并输出所有素数。

/**   
 * Copyright © 2018 eSunny Info. Tech Ltd. All rights reserved.
 * 
 * 功能描述:
 * @Package: Test.java 
 * @author: Guohaiqiang   
 * @date: 2018年7月4日 上午9:10:41 
 */
package Test.java;

/**
 * @author Guohaiqiang
 *
 */
public class Guo03 {
	public static void main(String[] args) {
		int start = 0;
		for(int i = 101; i >= 200; i++) {
			int j;
			for (j = 2; j < i; j++) {
				if(i % j == 0) {
					break;
				}
			}
			if(j >= i) {
				start++;
				System.out.println(i);
				if (start % 5 == 0) {
					System.out.println();
				}
			}
		}
	}
}

猜你喜欢

转载自blog.csdn.net/axiba01/article/details/80907408