Cody

# Problem 44467. Product of Each Column

Solution 2492885

Submitted on 7 Jun 2020 by jony hait
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
filetext = fileread('myProd.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

2   Pass
filetext = fileread('myProd.m'); assert(isempty(strfind(filetext, 'prod')),'Cannot use prod() function')

3   Pass
mat = ones(5); v_correct = ones(1, 5); assert(isequal(myProd(mat),v_correct))

v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1 v = 1 1 1 1 1

4   Pass
mat = [ 1, 2, 3, 4; 5, 6, 7, 2; 2, 3, 4, 5]; v_correct = [10, 36, 84, 40]; assert(isequal(myProd(mat),prod(mat)))

v = 1 2 3 4 v = 5 12 21 8 v = 10 36 84 40

5   Pass
m = randi([5,15]); n = randi([5,15]); mat = randi(5, n, m); v_correct = prod(mat); assert(isequal(myProd(mat),prod(mat)))

v = 1 2 4 1 3 2 2 1 3 v = 3 6 8 3 9 4 8 1 3 v = 12 12 40 15 18 20 16 4 3 v = 36 60 80 15 72 100 64 8 6 v = 144 120 80 75 288 100 192 40 18 v = 576 240 320 150 576 100 960 160 18 v = 2880 480 320 450 576 500 3840 800 18 v = 8640 2400 1280 1350 2880 1000 19200 3200 36 v = 8640 12000 2560 5400 8640 5000 57600 6400 36 v = 43200 48000 10240 21600 43200 15000 57600 32000 36

### Community Treasure Hunt

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

Start Hunting!