Cody

# Problem 44889. Given a matrix A return a vector of the product of the elements in each column using a loop without using prod.

Solution 1843772

Submitted on 9 Jun 2019 by Shlomi Shomonov
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = [8 10 9 9 1 8 3 2 4 4 10 4 6 2 7 7 1 6 4 1]; y_correct = [4480 120 648 288 28]; assert(isequal(ProdMat(x),y_correct))

x = 8 x = 64 x = 640 x = 4480 x = 10 x = 30 x = 120 x = 120 x = 9 x = 18 x = 108 x = 648 x = 9 x = 36 x = 72 x = 288 x = 1 x = 4 x = 28 x = 28

2   Pass
x = [7 4 1 4 5 3 7 5 7 1 6 6 6 9 8 2 2 8 6 7 9 8 4 9 6 7 5 1 2 8 9 3 5 5 7 9]; y_correct = [42 336 432 1728 540 1080 420 490 2520]; assert(isequal(ProdMat(x),y_correct))

x = 7 x = 7 x = 42 x = 42 x = 4 x = 24 x = 168 x = 336 x = 1 x = 6 x = 54 x = 432 x = 4 x = 24 x = 192 x = 1728 x = 5 x = 45 x = 180 x = 540 x = 3 x = 24 x = 216 x = 1080 x = 7 x = 14 x = 84 x = 420 x = 5 x = 10 x = 70 x = 490 x = 7 x = 56 x = 280 x = 2520

3   Pass
filetext = fileread('ProdMat.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

4   Pass
filetext = fileread('ProdMat.m'); assert(isempty(strfind(filetext, 'prod')),'prod() function is forbidden')

5   Pass
filetext = fileread('ProdMat.m'); assert(isempty(strfind(filetext, '!echo')),'!echo hacks are forbidden')

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!