POV-Ray : Newsgroups : povray.off-topic : Project Euler : Re: Project Euler Server Time
11 Oct 2024 13:15:01 EDT (-0400)
  Re: Project Euler  
From: Mueen Nawaz
Date: 27 Nov 2007 19:42:07
Message: <474cb95f$1@news.povray.org>
Warp wrote:
> John VanSickle <evi### [at] hotmailcom> wrote:
>> For instance, in the problem for summing the 
>> prime numbers less than one million, I'm not aware of any theorem which 
>> calculates such a sum for any range without testing each odd number for 
>> primality and then adding the primes.
> 
> http://en.wikipedia.org/wiki/Prime-counting_function

	I didn't read all of it, but it's not obvious how helpful that would
be...other than getting an idea of the number of primes under a million.
When you get that many then you can stop (assuming the estimate is good
enough).

	I'm not aware of any better way to do this than to simply get all the
primes under a million and add them up. The only variation is how one
obtains all the primes. You could use a Sieve method, or do what many
people did: Test each odd number by dividing it by all possible primes
less than sqrt(number). For all the prime problems, I was using a sieve,
but apparently for a lot of problems (all so far?), simply testing by
dividing appears to be faster. I think the sieve wins out once you the
numbers get large enough, though.

-- 
Diplomacy - the art of letting someone have your way.


                    /\  /\               /\  /
                   /  \/  \ u e e n     /  \/  a w a z
                       >>>>>>mue### [at] nawazorg<<<<<<
                                   anl


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.