KajitiSouls Wrote:Stereo, why would you set numbers concatenated with themselves as true? They aren't primes for the very obvious reason that they have a factor that is the parent prime. Other than that, I might take a look into your idea.
For comparison purposes.
ex 3 & 7 & 109 & 673 -> true for 3, 7, 109 and 673 (since all 4 numbers have a true in each of those 4 primes) -> they are a correct set of 4 primes.
Setting it true for itself just kinda indicates which number the array represents, instead of the normal "can concat with this number".
On further thought it might be worth the size hit to make the array of bits include all odd numbers (or all numbers of the form 6*k +- 1), for easier back conversion to what number an index represents. Not sure how often you'd use that function, though.
Code:
for(int j = 0; j < list.length && isCompatible; j++){
String num1 = "" + list[j] + nextPrime;
String num2 = "" + nextPrime + list[j];
long n1 = Long.parseLong(num1);
long n2 = Long.parseLong(num2);
if((primesTable.contains(n1) || isPrime(n1)) &&
(primesTable.contains(n2) || isPrime(n2))){
primesTable.put(n1, true);
primesTable.put(n2, true);
}Code:
get nextPrime
for i in Primes
compare nextPrime+i, i+nextPrime
if both prime
i.cat[nextPrime.index] = true
nextPrime.cat[i.index] = true
put nextPrime in Primes
nextPrime.cat[nextPrime.index] = trueCode:
check(n-tuple) returns n+1 tuple
for prime j in n-tuple
if(j.cat[nextPrime.index] && nextPrime.cat[j.index])
do nothing
else
return null
return nextPrime+n-tuple
