>CLEAR > >* *** main loop >FOR i=1 TO 4060 > IF IsPrime(i) = .T. > ?i > ENDIF >ENDFOR > >RETURN Gunnar -- Yes, there are several algorithms to calculate primes. The one you present looks like it fits the bill. My reference to maintaining the database of prime numbers is that one could cycle through primes, rather than ALL numbers between 1 and INT (n/2) as this one does, and perhaps save a second or two<g>. Jay > >* *** ******************************************************* >FUNC IsPrime(Num2Check) > LOCAL ; > xi, ; > TargetLoop, ; > ReturnValue > > ReturnValue = .T. > TargetLoop = ROUND(Num2Check/2, 0) > FOR xi=2 TO TargetLoop > IF MOD(Num2Check, xi) = 0 > ReturnValue = .F. > EXIT > ENDIF > ENDFOR > RETURN(ReturnValue) >ENDFUNC >