Boost logo

Boost :

From: Stephen Nutt (snutt_at_[hidden])
Date: 2003-09-17 17:37:16


Lucas,

If only prime number detection were that easy :) I do it the hard way,
divide the suspected prime by all numbers >=2 and <= the square root of the
candidate. I skip even numbers, but found it was easier to use all odd
numbers than to try and determine if the divisor were prime.

So to compile is_prime<450000007> I force the compiler to do well over
10,000 divisions before it comes back and says "you've got a prime on your
hands!"

Steve

----- Original Message -----
From: "Lucas Galfaso" <lgalfaso_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, September 17, 2003 8:58 AM
Subject: [boost] Re: Compile time prime numbers, powers and roots

> how you test if a number is prime. As you might know, verifying that
> m for a specific s, is not enough.
>
> Lucas/
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk