public java.util.ArrayList<Long> getPrimesLessThanX( long X )
    {
	readPrimeFile();
	java.util.ArrayList<Long> primeList = new java.util.ArrayList<Long>();
	long start = System.currentTimeMillis();
	if ( primes.size() == 0 )
	{
	    primes.add(Long.valueOf(2));
	    primes.add(Long.valueOf(3));
	}
	// okay we've read in the file, now we need to calculate any remaining primes
	// initialize potential prime to a value 2 greater than our greatest prime
	// we do this since if our greatest prime so far is 17 say, then the next prime 
	// will most certainly not be 18 (because its even) but could be 19 (which is true in this example)
	long potentialPrime = primes.get(primes.size()-1) + 2;
	boolean addedPrimes = false;
	// iterate until the last prime is >= X (to ensure that we have all primes < X
	while ( primes.get(primes.size()-1) < X )
	{    
	    boolean isAPrime = true; // default to true.
	    // now for each potential prime we need to iterate over all the existent primes to determine if the potential prime is a prime
	    for ( int i = 0; i < primes.size(); i++ )
	    {
		// get the value at primes list and if aPrime > the sqrt of potential prime break since we can stop (this is a simple optimization)
		long aPrime = primes.get(i).longValue();
	        if ( aPrime > Math.sqrt(potentialPrime) )
		{
		    break;
		}
		// potential prime needs to be determined if it is a prime, if any prime is modulus of 0 of potential prime then potential prime is NOT a prime
		if (potentialPrime % aPrime == 0 )
		{
		    isAPrime = false;
		    break;
		}
	    }
	    // if potential prime is a prime, then add it to the primes list
	    if ( isAPrime )
            {
                primes.add(Long.valueOf(potentialPrime));
		addedPrimes = true;
            }
	    potentialPrime += 2; // increment by 2 in order to skip all even numbers.
	}
	long stop = System.currentTimeMillis();
	//System.out.println("Calculated primes less than " + X + " in " + (stop - start) + "ms");
	if ( addedPrimes )
	{
	    writePrimeFile();
	}
	for ( Long prime : primes )
	{
	   if ( prime < X )
	   {
	      primeList.add(prime);
	   }
	}
	return primeList;
    }