On 5/22/07, Dan Bron <[EMAIL PROTECTED]> wrote:
Terrence,

You might consider that you can move your index up by more than one at every 
iteration.

When you're done with  2&pp  you already know that 4 is not a prime candidate.

yes, the next_prime function written by Raul would return 5 when I call
A next_prime 4

but per shootout rules:
http://shootout.alioth.debian.org/gp4/benchmark.php?test=nsievebits&lang=all

   *  create an array of M bit flags which represent either prime or not-prime
   * for each index number
         o test the flag value at that index
               + set or clear the flag values at multiples of that
index as necessary
               + if necessary keep and increment a separate count

so basically if (A next_prime 4) is not equal to 4, then I simply go
on to 5 and try
(A next_prime 5)  which will equal 5, so then I would continue with
(A process_prime) in that case...

I'm starting to see:
(A process_prime y) ` null_op  @. (A is_next_prime y)

I love these naive, verbose, in-elegant algorithms - they let me be
imperative in a functional language...


           rec  =:  {. , 1 , { (] (i.&1@:] $:^:(<#) *) 0 ~: |) (}.~ >:)~
           soe  =:  2 rec 0: 1} i.
           SoE  =:  I.@:soe

SoE is an abbreviation for what?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to