// Sieve of Eratosthenes n = eval[input["Enter highest number: "]] results = array[sieve[n]] println[results] println[length[results] + " prime numbers less than or equal to " + n] sieve[n] := { // Make an array containing the numbers from 0 to n. array = array[0 to n] array@1 = 0 // Don't consider 1 prime. for i = 2 to ceil[sqrt[n]] if array@i != 0 for j = i^2 to n step i array@j = 0 // Return the remaining elements where the element is not zero. return select[array, { |x| x != 0 }] }