码迷,mamicode.com
首页 > 其他好文 > 详细

求大于整数n的最小质数

时间:2020-03-20 22:29:09      阅读:74      评论:0      收藏:0      [点我收藏+]

标签:static   bool   java   scan   com   any   next   out   util   

package com.company.Util;

import java.util.Scanner;

public class Test09 {
public static void main(String[] args) {

System.out.println("-------------------------------------");

//----------------------------------------------------------
Scanner scanner = new Scanner(System.in);
int m= scanner.nextInt();
zuixiao(m);
}
public static void zuixiao(int n){
while(true){
n++;
if(zhiyou(n)){
System.out.println(n);
break;
}
}
}
public static boolean zhiyou(int s){
boolean flag=true;
int i;
for(i=2;i<s;i++){
if(s%i==0){

return false;
}}
return true;
}
}

求大于整数n的最小质数

标签:static   bool   java   scan   com   any   next   out   util   

原文地址:https://www.cnblogs.com/s999/p/12535087.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!