2009-01-18, 01:48 AM (This post was last modified: 2009-01-18, 01:51 AM by KajitiSouls.)
The new algorithm
Code:
import java.util.*;
public class Project60 {
//Find a set of five primes for which any two primes concatenate to produce another
//prime.
private static Hashtable<Long, Boolean> primesRecall = new Hashtable<Long, Boolean>();
private static ArrayList<Long> primesList = new ArrayList<Long>();
public static void main(String[] args){
double time = System.currentTimeMillis();
primesList.add(3L);
primesList.add(7L);
long nxtPrime = 11L;
int digitLimit = 4;
Okay, so after using Stereo's suggestion (nothing tricky with duplicate primes >_>), and meticulously testing each step of my new v3.0 algorithm, I have the results:
That's definitely an execution time of less than a minute =D Fitting a check to ensure that the sum of the 5 primes is the lowest is trivial at this point, aside from the "OutOfMemoryException" caused by the large-ass boolean table.
Thanks a lot Stereo and Devil's Sunrise! I've learned quite a few things from this exercise.