# Some simple code to print out the primes up to 100 # Leon Brocard # I1 holds the number we're currently checking for primality set I1, 1 # I2 holds the highest number we want to check for primality set I2, 100000 print "The primes up to " print I2 print " are:\n" # I1 counts up to I2 REDO: # I3 counts from 2 up to I4 (I1/2) set I3, 2 div I4, I1, 2 LOOP: # Check if I3 is a factor of I1 mod I5, I1, I3 if I5, OK # We've found a factor, so it can't be a prime and # we can skip right out of this loop and to the next # number branch NEXT OK: inc I3 le I3, I4, LOOP # We haven't found a factor so it must be a prime print I1 print "\n" NEXT: # Move on to the next number inc I1 le I1, I2, REDO end