编写一个函数,判断一个数是不是素数。在主函数中输入一个整数,输出是否是素数的信息。 实验步骤与要求:

[复制链接]
查看11 | 回复1 | 2012-6-12 13:54:32 | 显示全部楼层 |阅读模式
package Test;import java.util.*;public class tests {
public static void main(String[] args) {
System.out.println("请输入一个正整数:");
int a = (new Scanner(System.in)).nextInt();
if(prime(a) == true){
System.out.println(a+"是素数");
}
else{
System.out.println(a+"不是素数");
}...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行