What would be the output of the following code (in editor window)? [code]A=1:5; B=cumprod(A)[/code]

What would be the output of the following code (in editor window)?
Code:
A=1:5;
B=cumprod(A)
A. b=[1 2 6 24 120]
B. b=[1 2 3 4 5]
C. b=[5 4 3 2 1]
D. b=[120 24 6 2 1]
 
Answer: a
Explanation: B = cumprod(A) returns the cumulative product of A starting at the beginning of the first array dimension in A whose size does not equal 1. B(2) is the product of A(1) and A(2), while B(5) is the product of elements A(1) through A(5).
 

Tìm kiếm

Back
Top