Answer to Question #34020 in MatLAB | Mathematica | MathCAD | Maple for dothan

Question #34020

for a1=1:W
for a2=a1:W
for a3=a2:W
for a4=a3:W
for a5=i-a4-a3-a2-a1;
if(a4 <= a5 && a5<=W)
p2=[p2;a1,a2,a3,a4,a5];
end
end
end
end
end
end
Here if a1=1 then a2=1,2,3, if a1=2 then a2=2,3 and if a1=3 then a2=3. The same condition is for a3 & a4. Now I want to make this program only depends on "W" and "i" and I don't want to write a1,a2,a3,a4,a5.Because i need to run this code for i=4 and for a=2:4(a1 a2,a1 a2 a3,a1 a2 a3 a4)and again for i=5 and for a=2:4(a1 a2,a1 a2 a3,a1 a2 a3 a4,a1,a2,a3,a,a5).So i will be continue upto 17. and there are lot of values of "a".I just want to write "W,and i" and it will automatically generate value of "p2"

It’s the most wonderful time of the year: Winter Holidays! Thanksgiving dinner was served, Black Friday has finished, and now…

APPROVED BY CLIENTS

The assignment was completed correctly after a few inquiries back and forth with the expert. Once I advised which version of python I was using the correct solution was provided. Good cost and I got 100% on my assignment. Would recommend again and again!

## Comments

## Leave a comment