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 1837569

Submitted on 4 Jun 2019 by bentzi grinfeld
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))

k = 1 k = 8 k = 64 k = 640 k = 4480 k = 1 k = 10 k = 30 k = 120 k = 120 k = 1 k = 9 k = 18 k = 108 k = 648 k = 1 k = 9 k = 36 k = 72 k = 288 k = 1 k = 1 k = 4 k = 28 k = 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))

k = 1 k = 7 k = 7 k = 42 k = 42 k = 1 k = 4 k = 24 k = 168 k = 336 k = 1 k = 1 k = 6 k = 54 k = 432 k = 1 k = 4 k = 24 k = 192 k = 1728 k = 1 k = 5 k = 45 k = 180 k = 540 k = 1 k = 3 k = 24 k = 216 k = 1080 k = 1 k = 7 k = 14 k = 84 k = 420 k = 1 k = 5 k = 10 k = 70 k = 490 k = 1 k = 7 k = 56 k = 280 k = 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')