素数的判断

来源:互联网 发布:国际服务器端口定义 编辑:程序博客网 时间:2024/06/04 19:13
package hello;import java.util.Scanner;public class Hello { public static void main(String[] args) {  Scanner in = new Scanner(System.in);  int n;  n=in.nextInt();  int i=2,s=0,count=1;  for(i=2;i<n;i++)  {   s=n%i;   if(s==0)   {    count=0;    break;   }  }  if(count == 0)   System.out.print("不是素数");  else   System.out.print("是素数"); }}
0 0
原创粉丝点击