herrDeng網內搜尋

自訂搜尋

Ads

2015年11月20日 星期五

ex8找出小於500的正整數高斯質數(Gauss prime)

p為正整數且是高斯質數(Gauss prime):

  • p是質數
  • p=3(mod 4)

28 則留言:

b10133007 提到...

package ex01;public class b10133007 { static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); //int m1=(int)Math.sqrt(p); for(int i=2; i<=m; i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; } } System.out.println(); System.out.println(k); }}

A10433001 提到...

public class ex_01 { static boolean isPrime(int n){ if(n<1||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2;i<=m;i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0;n<=500;n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; } } System.out.println(k); }}

a10433029 提到...



public class ex29 { static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; }} System.out.println(); System.out.println(k); }

}

A10433006 提到...

public class ec { static boolean isPrime(int n){ if(n<1||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m;i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0;n<=500;n++){ if(isPrime(n) && n%4==3){ System.out.print(n+","); k++; } } System.out.print(k); }}

A10433018 提到...



public class GG1 { static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; }return true; }

public static void main(String[] args) { int p=0; for(int n=0; n<=500; n++){ if(isPrime(n) && n%4==3){ System.out.print(n+","); p++; } } System.out.println(p); }

}

A10433004 提到...

public class ex1120 { static boolean isPrime(int n){ if(n<1 || n==1) return false; int m=(int)Math.sqrt(n); for(int i=2;i<=m;i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int x=0; for(int n=0; n<=500; n++) { if(isPrime(n)&&n%4==3){ System.out.print(n+","); x++; } } System.out.println(); System.out.println(x); }}

A10433024 提到...



public class ex1 { static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; }return true; }

public static void main(String[] args) { int p=0; for(int n=0; n<=500; n++){ if(isPrime(n) && n%4==3){ System.out.print(n+","); p++; } } System.out.println(p); }

}

A10433019 提到...

public class hello123 {

static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; } } System.out.println(); System.out.println(k); }

}

A10433011 提到...

public class ex2 {

static boolean isPrime(int n){
if(n<1 ||n==1)return false;
int m= (int)Math.sqrt(n);
for (int i=2;i<m; i++){
if(n%i==0)return false;

}
return true;
}
public static void main (String[] args){
int x=0;
for(int n=0; n<=500;n++){
if(isPrime(n)&&n%4==3){
System.out.print(n+",");
x++;
}
}
System.out.println();
System.out.println(x);
}
}

A10433007 提到...

public class hello123 {

static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; } } System.out.println(); System.out.println(k); }

}

A10433010 提到...

public class hello123 {

static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; } } System.out.println(); System.out.println(k); }

}

A10433014 提到...

public class hello567 {

static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; } } System.out.println(); System.out.println(k); }

}

A10433003 提到...

public class hello1567 {

static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; } } System.out.println(); System.out.println(k); }

}

A10433011 提到...

public class ex2 { static boolean isPrime(int n){ if(n<1 ||n==1)return false; int m= (int)Math.sqrt(n); for (int i=2;i<=m; i++){ if(n%i==0)return false; } return true; } public static void main (String[] args){ int x=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); x++; } } System.out.println(); System.out.println(x); }}

A10433008 提到...

public class ec { static boolean isPrime(int n){ if(n<1||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m;i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0;n<=500;n++){ if(isPrime(n) && n%4==3){ System.out.print(n+","); k++; } } System.out.print(k); }}

A10433013 提到...

public class ex3 { static boolean abc(int n){ if(n<=3) return false; int m=(int)Math.sqrt(n); for(int i=2;i<=m;i++){ if(n%i==0) return false; if(n%4!=3) return false; } return true; } public static void main(String[] args) { int z=0; for(int n=0;n<=500;n++){ if(abc(n)){ System.out.print(n+","); z++;} } System.out.println(); System.out.println(z); }}

A10433022 提到...

public class ex3 { static boolean abc(int n){ if(n<=3) return false; int m=(int)Math.sqrt(n); for(int i=2;i<=m;i++){ if(n%i==0) return false; if(n%4!=3) return false; } return true; } public static void main(String[] args) { int z=0; for(int n=0;n<=500;n++){ if(abc(n)){ System.out.print(n+","); z++;} } System.out.println(); System.out.println(z); }}

A10433015 提到...

public class ZZZZZ { static boolean xas(int n){ if(n<4||n==1)return false ; int m=(int)Math.sqrt(n); for(int i=2;i<=m;i++){ if(n%i==0) return false; if(n%4!=3) return false; }return true ; } public static void main(String[] args) { int z=0; for (int n=0;n<=500;n++){ if(xas( n)){z++; System.out.print(n+",");} }System.out.println();System.out.println(z); }}

A10433043 提到...

public class ex3 { static boolean abc(int n){ if(n<=3) return false; int m=(int)Math.sqrt(n); for(int i=2;i<=m;i++){ if(n%i==0) return false; if(n%4!=3) return false; } return true; } public static void main(String[] args) { int z=0; for(int n=0;n<=500;n++){ if(abc(n)){ System.out.print(n+","); z++;} } System.out.println(); System.out.println(z); }}

A10433036 提到...

public class ex3 { static boolean abc(int n){ if(n<=3) return false; int m=(int)Math.sqrt(n); for(int i=2;i<=m;i++){ if(n%i==0) return false; if(n%4!=3) return false; } return true; } public static void main(String[] args) { int z=0; for(int n=0;n<=500;n++){ if(abc(n)){ System.out.print(n+","); z++;} } System.out.println(); System.out.println(z); }}

A10433028 提到...



public class dd { static boolean isPrime(int n){ if (n<=3) return false; int m=(int)Math.sqrt(n); for(int i=2;i<=m;i++){ if(n%i==0 || n%4!=3) return false; } return true; } public static void main(String[] args) { int z=0; for(int n=0;n<=500;n++){ if(isPrime(n)){ System.out.print(n+","); z++; } } System.out.println(); System.out.println(z); } }

A10433036 提到...

public class hello123 {

static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; } } System.out.println(); System.out.println(k); }

}

A10433043 提到...

public class hello123 {

static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; } } System.out.println(); System.out.println(k); }

}

A10433022 遲 提到...

public class hello123 {

static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; } } System.out.println(); System.out.println(k); }

}

A10433039 提到...

public class hello123 {

static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; } } System.out.println(); System.out.println(k); }

}

10433020 遲 提到...

public class hello123 {

static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; } } System.out.println(); System.out.println(k); }

}

A10433038 提到...

public class ex3 { static boolean abc(int n){ if(n<=3) return false; int m=(int)Math.sqrt(n); for(int i=2;i<=m;i++){ if(n%i==0) return false; if(n%4!=3) return false; } return true; } public static void main(String[] args) { int z=0; for(int n=0;n<=500;n++){ if(abc(n)){ System.out.print(n+","); z++;} } System.out.println(); System.out.println(z); }}

B10133189 提到...

public class hello {

static boolean isPrime(int n){ if(n<1 ||n==1) return false; int m=(int)Math.sqrt(n); for(int i=2; i<=m; i++){ if(n%i==0) return false; } return true; } public static void main(String[] args) { int k=0; for(int n=0; n<=500; n++){ if(isPrime(n)&&n%4==3){ System.out.print(n+","); k++; } } System.out.println(); System.out.println(k); }

}

Related Posts Plugin for WordPress, Blogger...

熱門文章