Re: prime number routine

puppet_sock_at_hotmail.com
Date: 02/10/04


Date: 10 Feb 2004 10:33:39 -0800


"don" <don@panix.com> wrote in message news:<c09uos$hjo$1@reader2.panix.com>...
> Ok, this is a homework assignment, but can you help me out anyway...... I
> need a routine for figuring out if a number inputted by the user is a prime
> number or not...... all I'm asking for is Not the exact code ( well maybe a
> little) but the logic or algorithm to tell whether or not a number is
> prime....

Precompute a big table of primes up to some maximum size.

Get your number. If it is smaller than the max, then
if it is in the table it is prime and if not not. Miller time.

If it is bigger than your max, then you have to start doing
some dividing. But first, you don't need to divide by anything
bigger than the square root of the number. (You have to explain
why.) And you don't need to divide by any number that is itself
not prime. (Again, you have to explain why.)

So, if your number is smaller than the square of the max of your
table, again, the scheme is pretty easy. You only need to divide
by the numbers in your table.

If your number is bigger than that, then you are on your own.
Socks



Relevant Pages

  • Re: Plus ca change wasRe:Well Ordered Sets
    ... When you take the square root of -1, you can choose +i or -i. ... Well-ordering has little to do with being "bigger" or being positive ... Moreover we can treat the set of events occupied by a particle in ... spacetime as a well ordered set. ...
    (sci.physics.relativity)
  • Plus ca change wasRe:Well Ordered Sets
    ... When you take the square root of -1, you can choose +i or -i. ... Well-ordering has little to do with being "bigger" or being positive ... Moreover we can treat the set of events occupied by a particle in ... spacetime as a well ordered set. ...
    (sci.physics.relativity)
  • Re: Fast Cube Root Using C33
    ... What is key is getting the initial estimate using the Kahan bit hack ... but that only works with IEEE floating point and not with TI floating ... Does anyone here remember how to take the square root of a decimal ... With machinery that can divide, ...
    (comp.dsp)
  • Re: Floating-Point Divide and Square Root Performance
    ... > It's trivial enough to get the peak FLOPS for multiply and addition ... > units that can give results every cycle. ... > the square root and divide on an architecture like the Itanium 2. ...
    (comp.arch.arithmetic)
  • Re: Pushing his luck.
    ... Nelson) divide be the square root of the average age of cocker ...
    (rec.motorcycles)