Created
April 12, 2020 01:13
-
-
Save joriki/eb40c036b2b81e462ccc3a86b7e18de9 to your computer and use it in GitHub Desktop.
Calculate abc-conjecture qualities for c,a power of three and two, respectively; see https://math.stackexchange.com/questions/3620950.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.math.BigInteger; | |
import java.util.Arrays; | |
import java.util.Locale; | |
public class Question3620950 { | |
final static long n = 0x80000000L; | |
public static void main (String [] args) { | |
boolean [] prime = new boolean [(int) (n >> 1)]; // prime [i] : is 2i + 1 prime? | |
Arrays.fill (prime,true); | |
prime [0] = false; | |
// pre-calculate primes using simple sieve of Eratosthenes | |
int limit = (int) Math.sqrt (n); // highest factor to test | |
for (int p = 3;p <= limit;p += 2) // loop over odd integers | |
if (prime [p >> 1]) // only test primes p | |
for (int k = 3*p;k > 0;k += 2*p) // loop over odd multiples of p | |
prime [k >> 1] = false; // sieve them out | |
BigInteger three = BigInteger.valueOf(3); | |
BigInteger twos; | |
BigInteger threes = BigInteger.ONE; | |
BigInteger last = BigInteger.ONE; | |
int k = -1; | |
for (int n = 1;n < 100;n++) { | |
threes = threes.multiply(three); | |
do { | |
twos = last; | |
last = twos.shiftLeft(1); | |
k++; | |
} while (last.compareTo(threes) < 0); | |
BigInteger b = threes.subtract(twos); | |
BigInteger rad = BigInteger.ONE; | |
outer: | |
for (long p = 3;p > 0;p += 2) | |
if (prime [(int) (p >> 1)]) { | |
BigInteger bigP = BigInteger.valueOf(p); | |
boolean first = true; | |
for (;;) { | |
BigInteger [] divAndRem = b.divideAndRemainder(bigP); | |
BigInteger div = divAndRem [0]; | |
if (div.compareTo(bigP) < 0) { | |
rad = rad.multiply(b); | |
break outer; | |
} | |
BigInteger rem = divAndRem [1]; | |
if (rem.signum() != 0) | |
break; | |
if (first) { | |
rad = rad.multiply(bigP); | |
first = false; | |
} | |
b = div; | |
} | |
} | |
System.out.println(n + "&" + k + "&" + threes.subtract(twos) + "&" + rad + "&" + String.format(Locale.US,"%.6f",Math.log(threes.doubleValue()) / Math.log(6 * rad.doubleValue())) + "\\\\"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment