Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Ultra-useful-primes/Java/ultra-useful-primes.java
Normal file
21
Task/Ultra-useful-primes/Java/ultra-useful-primes.java
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import java.math.BigInteger;
|
||||
|
||||
public final class UltraUsefulPrimes {
|
||||
|
||||
public static void main(String[] args) {
|
||||
for ( int n = 1; n <= 10; n++ ) {
|
||||
showUltraUsefulPrime(n);
|
||||
}
|
||||
}
|
||||
|
||||
private static void showUltraUsefulPrime(int n) {
|
||||
BigInteger prime = BigInteger.ONE.shiftLeft(1 << n);
|
||||
BigInteger k = BigInteger.ONE;
|
||||
while ( ! prime.subtract(k).isProbablePrime(20) ) {
|
||||
k = k.add(BigInteger.TWO);
|
||||
}
|
||||
|
||||
System.out.print(k + " ");
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue