BCX Console Demonstration Program s52.bas

 DIM A
 
 CLS
 FOR A = 1 TO 1000
   IF IsPrime(A) THEN ?  A;
 NEXT A
 
 FUNCTION IsPrime(Num!)
   LOCAL X!
   IF MOD(Num!, 2) = 0 THEN
     EXIT FUNCTION
   END IF
   FOR X! = 3 TO Num! - 1 STEP 2
     IF MOD(Num!, X!) = 0 THEN
       EXIT FUNCTION
     END IF
   NEXT X!
   FUNCTION = -1 ' Return true if it's a prime number 
 END FUNCTION

Result:


  Result not displayed for this example.