package cn.lhj.learn; /** * 输出1~n以内的素数 * * @author lhj * */ public class TestSuShu { public static void main(String[] args) { for (int i = 2; i <= 100; i++) { if (find(i)) { System.out.print(i + " "); } } } public static boolean find(int n) { for (int i = 2; i < Math.sqrt(n); i++) { if (n % i == 0) { return false; } } return true; } }