Hi James,
how small or lower order?
how often will you need to call it?
my argument against seive / brute force methods
is you end up gaining information about numbers along the way
that you may not have any use for.
if your largest prime is small enough you could try
loading or generating a list of primes and do a
binary search (or just use find)
On Thu, 29 Nov 2001, James Marsden wrote:
> Heh - I must admit I was testing it on relatively small primes - With what
> Joel sent in I'll have a bit of a redefine. The project only involves lower
> order primes currently but with larger primes my original equation is
> definitely slow :)
>
> James.
>
> ----- Original Message -----
> From: "Tom Conlin" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, November 29, 2001 8:28 AM
> Subject: [REBOL] Re: Speed testing prime functions..
>
>
> >
> > Hi James,
> >
> > seemed slower... hmmm, on what size number?
> > how about running them both on... say 1073741789
> >
> > you might want to run the other one first :)
> >
> >
> >
> >
> > On Thu, 29 Nov 2001, James Marsden wrote:
> >
> > > Hi to all the prime lovers out there :)
> > >
> > > Could someone give me some feedback on the fastest way to implement
> prime
> > > checks in Rebol -
> > >
> > > Currently I use:
> > >
> > > prime?: func [p /local c v][
> > > v: true
> > > for c 2 (p - 1) 1 [
> > > if p // c = 0 [v: false break]
> > > ]
> > > v
> > > ]
> > >
> > > Is there a better way to do this? I have seen another implementation
> but
> > > that was about 60 or so lines and seemed slower...
> > >
> > >
> > > James.
> > >
> > > --
> > > To unsubscribe from this list, please send an email to
> > > [EMAIL PROTECTED] with "unsubscribe" in the
> > > subject, without the quotes.
> > >
> >
> > --
> > To unsubscribe from this list, please send an email to
> > [EMAIL PROTECTED] with "unsubscribe" in the
> > subject, without the quotes.
> >
>
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
>
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.