You are viewing a single comment's thread from:
RE: The Sieve of Eratosthenes: An Ancient Greek Method of Finding Primes
This is a really cool method! Here is an implementation of it I put together in octave for a course earlier this year:
function [list] = primeList (n)
isPrime = ones(1,n); % one is not prime
isPrime(1,1) = 0;
list = [];
for i = 2:n
if(isPrime(1,i) == 1)
list = horzcat(list,i);
for j = (i^2):i:n
isPrime(1,j) = 0;
end
end
end
end
Awesome