~ PRIMEX.MSE - lrb - 6/29/2010 "!Enter a number in the range [2,32767] : "?Q: Q.1-l:Q.20+Q:(Q.l.-^"!"Q.!" : "#G,Q.,2;Q.1-Q:Q.10\0=["!!Strike Any Key ... "?']) "!" ~ find a prime factor of 1% using 2% as the initial candidate $G1%n:2%f: ~ 2 is special; if it's a candidate and not a divisor, start w/ 3 2%2=[n.2\[3f:]] (n.f.\^f.2+f:) ~ f is now the smallest factor of n ~ this figures out how often f goes into n 1c:n.f./d:f.g:(d.f.\0=^1c.+c:d.f./d:g.f.*g:) ~ print it (possibly w/ an exponent) followed by a space f.!c.1>['^!'c.!]" " g.n.<[#G,d.,f.;] ~ call self if not done f.Q.=["is prime."]@