# 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 &lt;= a5 && a5&lt;=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 &quot;W&quot; and &quot;i&quot; 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 &quot;a&quot;.I just want to write &quot;W,and i&quot; and it will automatically generate value of &quot;p2&quot;
0
Expert's answer

#### Not answered

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

#### Comments

No comments. Be the first!

### Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS