How about solving the problem for large integers?
If the argument is less than 2^31 a table-driven
approach should be most efficient (but much less
interesting). As it is:
npp n=: 3^20x
|domain error: npp
| npp n=:3^20
p:^:_1 n
|domain error
| p:^:_1 n
----- Original Message -----
From: "Miller, Raul D" <[EMAIL PROTECTED]>
Date: Thursday, September 21, 2006 9:25 am
Subject: RE: [Jprogramming] Explicit to Tacit - newbie question
> The code I posted earlier today was rather mutilated by the
> email client I used to post it. Unfortunately, this
> mutilation was invisible to me as long as I was using that
> client.
>
> Here's a corrected version:
> npp=: (((i. <./)@:|@:- { ]) ,@(i.@>:&.(p:^:_1) ^/ [EMAIL PROTECTED]@#:))"0
>
> Also, the first phrase breakout should have been:
> i.@>:&.(p:^:_1) generates a list of relevant primes
>
> I apologize on behalf of myself and on behalf of Microsoft.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm