[Tutor] List Splicing

Emile van Sebille emile at fenx.com
Thu Jun 18 00:25:11 CEST 2009

On 6/17/2009 3:03 PM Robert Berman said...
> Greetings,
> I am working on a 'simple' algorithm to solve the problem called PRIME1
> explained at http://www.spoj.pl/problems/PRIME1/. 
> I do have an algorithm based on the Sieve of Eratosthenes and it does
> work as I am failing the project not because of a computational error
> but because of the dreaded TLE (time limit exceeded) designator. I have
> determined there are at least 3 areas for improvement. The first is
> within my code where I am creating a list of the first million primes. 

It looks more like it creates a list 1000001 in length where the 
non-zero numbers in that list are primes.  I'd try BuildSieve(100) until 
BuildSieve was returning just primes.

Or, are you trying to create a list of the primes under 1000000?

Optimization should proceed once you've got it working.


More information about the Tutor mailing list