判断是否是质数
程序员文章站
2023-12-28 17:32:28
...
java 代码
- import java.io.*;
- class Text{
- public static void main(String [] args)throws Exception{
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- String str = br.readLine();
- int val = Integer.parseInt(str);
- int ix=0;
- for(ix=2;ix<val;++ix){
- if(val%ix==0){
- break;
- }
- }
- if(val == ix)
- System.out.println("yes it is");
- else
- System.out.println("No it is not");
- }
- }