simple coding, how to write (x-1)...(x-n)
1 view (last 30 days)
Show older comments
How would i write (x-1)(x-2)....(x-n)
for a given n in matlab
0 Comments
Answers (2)
Image Analyst
on 5 Sep 2016
Try this:
result = 1
for k = 1 : n
result = result * (x - k);
end
2 Comments
Image Analyst
on 5 Sep 2016
You can do this:
result = 1
for k = 1 : length(z)
result = result * (x - z(k));
end
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!