Zeno (programming Language) - Example: Sieve of Eratosthenes

Example: Sieve of Eratosthenes

const N : int := 5000 var a : array of boolean program var i, j : int init_a % initialize array for i := 2...floor ( N/2 ) do for j := 2...floor ( N/i ) do a := false % mark as not prime end for end for j := 0 for i := 2...N do % output results if a then % is prime put i : 6 ... incr j if (j mod 5) = 0 then % start new line put "" end if end if end for end program % initialize the array procedure init_a var i : int for i := 1...N do a := true end for end procedure

Sample output

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113

Read more about this topic:  Zeno (programming Language)

Famous quotes containing the word sieve:

    They went to sea in a Sieve, they did,
    In a Sieve they went to sea:
    In spite of all their friends could say,
    On a winter’s morn, on a stormy day,
    Edward Lear (1812–1888)