`
san_yun
  • 浏览: 2594924 次
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

判断是否是质数

阅读更多
java 代码
  1. import java.io.*;   
  2. class Text{   
  3.     
  4.  public static void main(String [] args)throws Exception{   
  5.   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));   
  6.   String str = br.readLine();   
  7.      int val = Integer.parseInt(str);   
  8.      int ix=0;   
  9.      for(ix=2;ix<val;++ix){   
  10.          
  11.       if(val%ix==0){   
  12.        break;    
  13.       }   
  14.          
  15.      }   
  16.       if(val == ix)   
  17.       System.out.println("yes it is");   
  18.       else  
  19.       System.out.println("No it is not");    
  20.  }    
  21. }   
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics