You don't need to check any other even divisor than 2. Therefore more efficient is to check 2 then FOR I=3 TO MAX STEP 2.
An even more efficient mechanism is to limit the divisors to known prime numbers, but let's not get into there. Maximally efficient, of course, is not to reinvent the wheel at all, and use the PRIME verb. ----- Original Message ----- From: "Mark Johnson" <[EMAIL PROTECTED]> To: u2-users@listserver.u2ug.org Subject: Re: [U2] Prime number file modulos Date: Fri, 2 Sep 2005 23:43:41 -0400 > > Here's one better if you don't want to > EXECUTE "PRIME 123" CAPTURING REC > > INPUT ANS > MAX=INT(SQRT(ANS))+1 > PRIME=TRUE > FOR I=2 TO MAX UNTIL NOT PRIME > IF MOD(ANS,I)=0 THEN PRIME=FALSE > NEXT I > > Add your own frosting on this very simple prime calculation. The max number > of divisors to test is the SQRT of the object plus 1 to accommodate the > fraction. I learned this method in a 1974 Fortran class in college. > > My 1 cent > Mark Johnson > Happy Labor Day ------- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/