Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

How to do that.the product of four consecutive even integers is 13440. Using Matlab?

Asked by pitchaorn

pitchaorn (view profile)

on 20 Sep 2013

the product of four consecutive even integers is 13440. Using Matlab's build-in function for operations with polynomials, determine the four integers.

I don't know how to do that

answer is 8 10 12 14

help me please

0 Comments

pitchaorn

pitchaorn (view profile)

Products

No products are associated with this question.

4 Answers

Answer by Jos (10584)

Jos (10584) (view profile)

on 20 Sep 2013
Accepted answer

One approach is to use brute force:

N = 13440 ;
for k = 2:N
    v = k + [0:2:6] ;
    p = prod(v) ;    
    if prod(v)==N,
        disp('N is the product of :') ;
        disp (v)
        break 
    elseif prod(v) > N
        disp('There is no solution')
        break
    end
end

There are many optimalisations that can be made ...

4 Comments

Jos (10584)

Jos (10584) (view profile)

on 20 Sep 2013

Note that this does not use polynomials, so it is not a real answer to your (homework?) question ...

pitchaorn

pitchaorn (view profile)

on 20 Sep 2013

Yes, I think my teacher want my answer make from polynomials.

pitchaorn

pitchaorn (view profile)

on 23 Sep 2013

Your answer is correct so thank you. But I change v to v=x*(x+2)*(x+4)*(x+6) and if v==N. My teacher told me "x*(x+2)*(x+4)*(x+6)" is polynomials.

Jos (10584)

Jos (10584) (view profile)

Answer by Image Analyst

Image Analyst (view profile)

on 20 Sep 2013

y = x*(x+2)*(x+4)*(x+6)

= x*(x+2)*(x^2+10X+24)

= x * ( x^3+10x^2+24x + 2x^2+20X+48)

= x^4 + .... and so on.

Then subtract 13440 and use fzero to determine the root. Perhaps that's what he meant.

2 Comments

Image Analyst

Image Analyst (view profile)

on 20 Sep 2013

Visualizing it helps:

x = -20:10;
y = x.*(x+2).*(x+4).*(x+6);
plot(x,y, 'bs-', 'LineWidth', 3);
xl = xlim;
% Plot a horizontal line at y = 13440
line([xl(1), xl(2)], [13440, 13440], ...
'Color', [1,0,0], 'LineWidth', 3);
grid on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
pitchaorn

pitchaorn (view profile)

on 23 Sep 2013

Thank you for answer

Image Analyst

Image Analyst (view profile)

Answer by Matt J

Matt J (view profile)

on 20 Sep 2013
Edited by Matt J

Matt J (view profile)

on 20 Sep 2013

Hint: What if you solved the polynomial equation

 x*(x+2)*(x+4)*(x+6)=13440

using MATLAB's commands POLY and ROOTS?

2 Comments

Matt J

Matt J (view profile)

on 20 Sep 2013

If you follow this approach, you will also find that an additional solution is [-14 -12 -10 -8], which might earn you bonus points!

pitchaorn

pitchaorn (view profile)

on 23 Sep 2013

Yes, i find soulution because your answer.Thank you for answer

Matt J

Matt J (view profile)

Answer by Sean de Wolski

Sean de Wolski (view profile)

on 20 Sep 2013

Obligatory one-liner:

vals = 2*find(prod(bsxfun(@plus,(2:2:13440).',0:2:6),2)==13440)+[0:2:6]

1 Comment

pitchaorn

pitchaorn (view profile)

on 23 Sep 2013

Thank you for answer

Sean de Wolski

Sean de Wolski (view profile)

Contact us