% Problem 6
% Find the sum of all the multiples of 3 or 5 below 1000
% Mohsin Javed, Oct 6, 2015

N = 1000-1;
mask = false(1, N);
% Mark the multiples of 3:
mask(3:3:end) = true;
% Mark the multiples of 5:
mask(5:5:end) = true;

% Numbers from 1:N
n = 1:N;
% Add the numbers indicated by mask:
sum(n(mask))