! Prime_test, Version 1, 6 June 2003 ! Tests numbers from 1 to 100 for primeness ! ******************* LIBRARIES and DECLARATIONS ******************* DECLARE FUNCTION prime ! *************************** CONSTANTS **************************** LET true = 1 LET false = 0 ! **************************** VARIABLES *************************** ! Variables are initialized and described ! Arrays are defined and described ! ************************** MAIN PROGRAM ************************** FOR i=1 TO 100 IF prime(i) = true THEN PRINT i, NEXT i ! ******************* SUBROUTINES and FUNCTIONS ******************** FUNCTION Prime(number) ! Tests for primeness of a number ! Number is not a prime if any number from 1 to SquareRoot(number) ! evenly divides the number FOR i=2 TO Sqr(number) ! Sqr(n) = square root IF number/i = Int(number/i) THEN ! Int(n) = integer portion LET Prime = false EXIT FUNCTION END IF NEXT i LET Prime = true END FUNCTION END