% Problem 7: Find the smallest positive number that is divisible by all of the % numbers from 1 to 10. % % Mohsin Javed, Oct 6, 2015 %% % Closed form answer: n = prod(primes(10))*2*2*3 %% % Start with the lowest candidate, which is 10 in this case: n = 10; % What are the quotients when we divide n with numbers from 1 to 10: q = n./(1:10); % If any of the quotients is not an integer, the division was not exact, % check this and keep looping until you find the first n which satisfies % this condition: while ( any(ceil(q) ~= floor(q)) ) % Increment n: n = n + 1; % and check the quotients again: q = n./(1:10); end n