function sieve ( start_range, end_range )
% Find all the prime numbers between start_range and end_range.
%   We use a simple sieve-of-Eratosthenes method within this range.
%
% Print all the prime numbers found within that range to the screen.
%
% Usage:        sieve (start_range, end_range)
%
%       where       start_range      is start of range to check (inclusive)
%
%                   end_range        is end of range to check (inclusive)
%
% MWR 12/13/2011

% set this to 1 to see diagnostic messages
global g_debug;
g_debug = 0;

for candidate = start_range : end_range
    if (g_debug > 0)
        fprintf(1, ' next number to check is %d \n', candidate);
    end

    if (is_a_prime(candidate) == 1)
        fprintf(1, '%d \n', candidate);
    end

end

end


% This subroutine checks to see if the given integer is prime,
%    using a brute-force technique, but halting when it reaches
%    the square root of the integer
%
% Returns
%           1     if the number is prime
%           0     if not
%
function [ yes ] = is_a_prime ( number )

global g_debug;

yes = 1;

for i = 2 : sqrt(number) + 1
    div = number / i;
    if (floor(div) == div)
        if (g_debug > 0)
            fprintf(1, ' factor %d exactly divides candidate %d \n', div, number);
        end
        yes = 0;
        break;
    end
end

end
Error using sieve (line 19)
Not enough input arguments.