Primes by Trial Division - Acornsoft Logo
16 February 2018
Acornsoft Logo is similar to DR LOGO, with some small syntactical changes. Lists may not span lines in the editor.
TO PRIMES :N LOCAL "PRIMES [] LOCAL "COUNT 2 LOCAL "FOUND 0 CONTINUE: CATCH "NOTPRIME [ LOCAL "I 1 REPEAT :FOUND [ IF REMAINDER :COUNT ITEM :I :PRIMES = 0 [ THROW "NOTPRIME ] [ MAKE "I (SUM 1 :I) ] ] PRINT :COUNT MAKE "PRIMES (LPUT :COUNT :PRIMES) MAKE "FOUND (SUM 1 :FOUND) ] MAKE "COUNT (SUM 1 :COUNT) IF :FOUND < :N [ GO "CONTINUE ] END