#COMPILE EXE "s95_prime_check.exe"
' Sample: Prime number checker
FUNCTION IsPrime(BYVAL n AS LONG) AS LONG
    DIM i AS LONG
    IF n < 2 THEN FUNCTION = 0: EXIT FUNCTION
    FOR i = 2 TO SQR(n)
        IF n MOD i = 0 THEN FUNCTION = 0: EXIT FUNCTION
    NEXT i
    FUNCTION = 1
END FUNCTION
FUNCTION PBMAIN() AS LONG
    DIM i AS LONG, count AS LONG
    PRINT "Prime numbers 1-50:"
    count = 0
    FOR i = 2 TO 50
        IF IsPrime(i) THEN
            PRINT i;
            INCR count
            IF count MOD 10 = 0 THEN PRINT
        END IF
    NEXT i: PRINT
    FUNCTION = 0
END FUNCTION
