Cody

# Problem 3075. Matrix of Multiplication Facts

Solution 3049063

Submitted on 3 Oct 2020 by mohsen
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 = [6 8 ; 15 20]; y=factor_square(x) assert(all(y(:)==round(y(:)))) assert(isequal(y(2)*y(4),x(1))) assert(isequal(y(2)*y(6),x(2))) assert(isequal(y(4)*y(8),x(3))) assert(isequal(y(6)*y(8),x(4))) assert(size(y,1)==3); assert(size(y,2)==3);

y = 6 y = 6 0 15 y = 6 0 15 0 0 0 8 y = 6 0 15 0 0 0 8 0 20 ans = 6 0 8 0 0 0 15 0 20 f1 = 2 3 f2 = 3 5 f3 = 2 2 2 f4 = 2 2 5 y = 6 3 15 0 0 0 8 0 20 y = 6 3 15 0 0 5 8 0 20 y = 6 3 15 0 0 5 8 4 20 y = 6 3 15 2 0 5 8 4 20 y = 6 2 8 3 0 4 15 5 20 y = 6 2 8 3 0 4 15 5 20

2   Pass
x=[35 42 ; 15 18]; y=factor_square(x) assert(all(y(:)==round(y(:)))) assert(isequal(y(2)*y(4),x(1))) assert(isequal(y(2)*y(6),x(2))) assert(isequal(y(4)*y(8),x(3))) assert(isequal(y(6)*y(8),x(4))) assert(size(y,1)==3); assert(size(y,2)==3);

y = 35 y = 35 0 15 y = 35 0 15 0 0 0 42 y = 35 0 15 0 0 0 42 0 18 ans = 35 0 42 0 0 0 15 0 18 f1 = 5 7 f2 = 3 5 f3 = 2 3 7 f4 = 2 3 3 y = 35 5 15 0 0 0 42 0 18 y = 35 5 15 0 0 3 42 0 18 y = 35 5 15 0 0 3 42 6 18 y = 35 5 15 7 0 3 42 6 18 y = 35 7 42 5 0 6 15 3 18 y = 35 7 42 5 0 6 15 3 18

3   Pass
x = [432 288 ; 288 192]; y=factor_square(x) assert(all(y(:)==round(y(:)))) assert(isequal(y(2)*y(4),x(1))) assert(isequal(y(2)*y(6),x(2))) assert(isequal(y(4)*y(8),x(3))) assert(isequal(y(6)*y(8),x(4))) assert(size(y,1)==3); assert(size(y,2)==3);

y = 432 y = 432 0 288 y = 432 0 288 0 0 0 288 y = 432 0 288 0 0 0 288 0 192 ans = 432 0 288 0 0 0 288 0 192 f1 = 2 2 2 2 3 3 3 f2 = 2 2 2 2 2 3 3 f3 = 2 2 2 2 2 3 3 f4 = 2 2 2 2 2 2 3 y = 432 3 288 0 0 0 288 0 192 y = 432 3 288 0 0 96 288 0 192 y = 432 3 288 0 0 96 288 2 192 y = 432 3 288 144 0 96 288 2 192 y = 432 144 288 3 0 2 288 96 192 y = 432 144 288 3 0 2 288 96 192

4   Pass
x = [21 63 ; 15 45]; y=factor_square(x) assert(all(y(:)==round(y(:)))) assert(isequal(y(2)*y(4),x(1))) assert(isequal(y(2)*y(6),x(2))) assert(isequal(y(4)*y(8),x(3))) assert(isequal(y(6)*y(8),x(4))) assert(size(y,1)==3); assert(size(y,2)==3);

y = 21 y = 21 0 15 y = 21 0 15 0 0 0 63 y = 21 0 15 0 0 0 63 0 45 ans = 21 0 63 0 0 0 15 0 45 f1 = 3 7 f2 = 3 5 f3 = 3 3 7 f4 = 3 3 5 y = 21 3 15 0 0 0 63 0 45 y = 21 3 15 0 0 5 63 0 45 y = 21 3 15 0 0 5 63 9 45 y = 21 3 15 7 0 5 63 9 45 y = 21 7 63 3 0 9 15 5 45 y = 21 7 63 3 0 9 15 5 45

5   Pass
x = [110 132 ; 130 156]; y=factor_square(x) assert(all(y(:)==round(y(:)))) assert(isequal(y(2)*y(4),x(1))) assert(isequal(y(2)*y(6),x(2))) assert(isequal(y(4)*y(8),x(3))) assert(isequal(y(6)*y(8),x(4))) assert(size(y,1)==3); assert(size(y,2)==3);

y = 110 y = 110 0 130 y = 110 0 130 0 0 0 132 y = 110 0 130 0 0 0 132 0 156 ans = 110 0 132 0 0 0 130 0 156 f1 = 2 5 11 f2 = 2 5 13 f3 = 2 2 3 11 f4 = 2 2 3 13 y = 110 5 130 0 0 0 132 0 156 y = 110 5 130 0 0 26 132 0 156 y = 110 5 130 0 0 26 132 6 156 y = 110 5 130 22 0 26 132 6 156 y = 110 22 132 5 0 6 130 26 156 y = 110 22 132 5 0 6 130 26 156

6   Pass
p=primes(1000); j=randperm(numel(p)); p=p(j(1:4)); x=[p(1)*p(2) p(1)*p(3) ; p(2)*p(4) p(3)*p(4)] y=factor_square(x) assert(all(y(:)==round(y(:)))) assert(isequal(y(2)*y(4),x(1))) assert(isequal(y(2)*y(6),x(2))) assert(isequal(y(4)*y(8),x(3))) assert(isequal(y(6)*y(8),x(4))) assert(size(y,1)==3); assert(size(y,2)==3);

x = 166121 132161 25241 20081 y = 166121 y = 166121 0 25241 y = 166121 0 25241 0 0 0 132161 y = 166121 0 25241 0 0 0 132161 0 20081 ans = 166121 0 132161 0 0 0 25241 0 20081 f1 = 283 587 f2 = 43 587 f3 = 283 467 f4 = 43 467 y = 166121 587 25241 0 0 0 132161 0 20081 y = 166121 587 25241 0 0 43 132161 0 20081 y = 166121 587 25241 0 0 43 132161 467 20081 y = 166121 587 25241 283 0 43 132161 467 20081 y = 166121 283 132161 587 0 467 25241 43 20081 y = 166121 283 132161 587 0 467 25241 43 20081

7   Pass
p=primes(100000); p(p<50000)=[]; j=randperm(numel(p)); p=p(j(1:4)) x=[p(1)*p(2) p(1)*p(3) ; p(2)*p(4) p(3)*p(4)] y=factor_square(x) assert(all(y(:)==round(y(:)))) assert(isequal(y(2)*y(4),x(1))) assert(isequal(y(2)*y(6),x(2))) assert(isequal(y(4)*y(8),x(3))) assert(isequal(y(6)*y(8),x(4)))

p = 84307 91571 80173 85133 x = 1.0e+09 * 7.7201 6.7591 7.7957 6.8254 y = 7.7201e+09 y = 1.0e+09 * 7.7201 0 7.7957 y = 1.0e+09 * 7.7201 0 7.7957 0 0 0 6.7591 y = 1.0e+09 * 7.7201 0 7.7957 0 0 0 6.7591 0 6.8254 ans = 1.0e+09 * 7.7201 0 6.7591 0 0 0 7.7957 0 6.8254 f1 = 84307 91571 f2 = 85133 91571 f3 = 80173 84307 f4 = 80173 85133 y = 1.0e+09 * 7.7201 0.0001 7.7957 0 0 0 6.7591 0 6.8254 y = 1.0e+09 * 7.7201 0.0001 7.7957 0 0 0.0001 6.7591 0 6.8254 y = 1.0e+09 * 7.7201 0.0001 7.7957 0 0 0.0001 6.7591 0.0001 6.8254 y = 1.0e+09 * 7.7201 0.0001 7.7957 0.0001 0 0.0001 6.7591 0.0001 6.8254 y = 1.0e+09 * 7.7201 0.0001 6.7591 0.0001 0 0.0001 7.7957 0.0001 6.8254 y = 1.0e+09 * 7.7201 0.0001 6.7591 0.0001 0 0.0001 7.7957 0.0001 6.8254

### Community Treasure Hunt

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

Start Hunting!