the product of three consecutive integers is 1716. find that integer in matlab

Here's a solution in Matlab:

main.m
n = nthroot(1716,3);   % find the cube root of 1716
x = floor(n);          % round down to the nearest integer
while x*(x+1)*(x+2) ~= 1716  % check if x, x+1, x+2 is equal to 1716
    x = x + 1;         % increment x if the product is not equal to 1716
end
disp(x);               % display the integer x
304 chars
7 lines

The output of this code is:

main.m
6
2 chars
2 lines

So the three consecutive integers whose product is 1716 are 6, 7, and 8.

gistlibby LogSnag