- class JuegePrimeTest{
- public static void main(String[] args) {
- int count=0;
- for( int num=1;num<100;num++){
- if(judgePrime(num)){
- if(count++%10!=0){
- System.out.print(num+" ");
- }
- else
- System.out.println();
- }
-
- }
-
- }
-
- public static boolean judgePrime(int num) {
- for( int i=2; i<=Math.sqrt(num);i++){
- if(num%i==0)
- return true;
- }
- return false;
- }
-
- }
复制代码 |
|