Ok, so I was bored a few weeks ago... :-)
----
lnCalcTo = 10000
lnSieveEnd = SQRT(lnCalcTo)
WAIT WINDOW "Populating integers up to " + TRANSFORM(lnCalcTo) NOWAIT
CREATE CURSOR Sieve (iNumber I, cStatus C(1))
FOR i = 1 TO lnCalcTo
INSERT INTO Sieve VALUES (i, "P")
ENDFOR
*!* 1 isn't prime
GO TOP
REPLACE cStatus WITH "N"
WAIT WINDOW "Record 2" NOWAIT
lnLastOdo = 2
SCAN FOR BETWEEN(RECNO(), 2, lnSieveEnd)
SCAN WHILE cStatus = "N" AND iNumber < lnSieveEnd
ENDSCAN
IF iNumber ^ 2 > lnCalcTo
LOOP
ENDIF
lnRecNo = RECNO()
GO (lnRecNo ^ 2)
REPLACE REST cStatus WITH "N" ;
FOR MOD(iNumber, lnRecNo) = 0 AND cStatus = "P"
GO (lnRecNo)
IF lnRecNo > lnLastOdo + 20
WAIT WINDOW "Record " + TRANSFORM(lnRecNo) NOWAIT
lnLastOdo = lnRecNo
ENDIF
ENDSCAN
WAIT CLEAR
BROWSE FIELDS iNumber :H="Primes" FOR cStatus="P"
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.