Data update
This commit is contained in:
parent
5af6d93694
commit
796d366b97
455 changed files with 7413 additions and 1900 deletions
26
Task/Repunit-primes/Java/repunit-primes.java
Normal file
26
Task/Repunit-primes/Java/repunit-primes.java
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import java.math.BigInteger;
|
||||
|
||||
public final class RepunitPrimes {
|
||||
|
||||
public static void main(String[] aArgs) {
|
||||
final int limit = 2_700;
|
||||
System.out.println("Repunit primes, up to " + limit + " digits, in:");
|
||||
for ( int base = 2; base <= 16; base++ ) {
|
||||
System.out.print(String.format("%s%2s%s", "Base ", base, ": "));
|
||||
String repunit = "";
|
||||
while ( repunit.length() < limit ) {
|
||||
repunit += "1";
|
||||
if ( BigInteger.valueOf(repunit.length()).isProbablePrime(CERTAINTY_LEVEL) ) {
|
||||
BigInteger value = new BigInteger(repunit, base);
|
||||
if ( value.isProbablePrime(CERTAINTY_LEVEL) ) {
|
||||
System.out.print(repunit.length() + " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
private static final int CERTAINTY_LEVEL = 20;
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue