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.  
So, at the end of  3&pp  you could advance to  5&pp  .  That is,  you could 
shorten:

           5 pp 4 pp 3 pp 2 pp A 

to:

           5 pp      3 pp 2 pp A 

But, of course, you cannot know this in advance; you have to update your index 
at the end of every  pp  .  So you couldn't use scan.

But you could, for example, recurse:

           rec  =:  {. , 1 , { (] (i.&1@:] $:^:(<#) *) 0 ~: |) (}.~ >:)~
           soe  =:  2 rec 0: 1} i.
           SoE  =:  I.@:soe
           
           SoE 20
        2 3 5 7 11 13 17 19


-Dan

PS to Roger:  There's another bug in   f.  wrt  $:  :

           dyd =. [ $: ] 
           bob =. 'x' dyd ]
           bob f.
        'x' 4 : 'x [ $: ] y' ]
           
The fixed form of  bob  should have parenthesis around the verb within the 
explicit definition, like so:

        'x' 4 : 'x([ $: ])y' ]

The problem is the original  dyd  is defined with a train of verbs, but its 
fixed counterpart is not.

(bug report entitled:  TRAIN DERAILED  or  FIXED VERBS BROKEN :)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to