用提高效率的暴力法求3000以内的素数

public class At 
{

	public static void main(String[] args) 
	{
		int haha;
		for(int i=2;i<=3000;i++)
		{
		   haha=0;
			for(int j=2;j<Math.sqrt(i);j++)//关键
			{
				if(i%j==0)
				{
					haha=1;
					break;
				}
			}
			if(haha==0)
				System.out.print(i+"  ");
			
		}

	}

}

原文地址:https://www.cnblogs.com/iamjuruo/p/7470928.html