您的位置 首页 java

Java求m,n之间的素数的个数(m

package test;

import Java .util.Scanner;

public class IsPrime {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int m = sc.nextInt();

int n =sc.nextInt();

}

private static void isPrime(int m,int n){

int j,k;

int amount = 0;//素数的个数(已知m<n)

j = m;

k = n;

for (int i = j; i <= n; i++) {

int temp = 0;

for (int t = 1; t <= i; t++) {

if(i%t==0){

temp++;

}

}

if(temp<=2){

amount++;

}

}

System.out.println(“素数总数是”+amount);

}

}

文章来源:智云一二三科技

文章标题:Java求m,n之间的素数的个数(m

文章地址:https://www.zhihuclub.com/178639.shtml

关于作者: 智云科技

热门文章

网站地图