Cody

# Problem 42615. Factorizing a number into a given number of factors

Solution 2718768

Submitted on 21 Jul 2020 by Rafael S.T. Vieira
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
n = 30; b = 1; A_correct = [ 30 ]; assert(isequal(LtdFactor(n,b),A_correct))

2   Pass
n = 3135; b = 2; A_correct = [ 1 3135 ; 3 1045 ; 5 627 ; 11 285 ; 15 209 ; 19 165 ; 33 95 ; 55 57 ]; assert(isequal(LtdFactor(n,b),A_correct))

3   Pass
n = 120; b = 3; A_correct = [ 1 1 120 ; 1 2 60 ; 1 3 40 ; 1 4 30 ; 1 5 24 ; 1 6 20 ; 1 8 15 ; 1 10 12 ; 2 2 30 ; 2 3 20 ; 2 4 15 ; 2 5 12 ; 2 6 10 ; 3 4 10 ; 3 5 8 ; 4 5 6 ]; assert(isequal(LtdFactor(n,b),A_correct))

4   Pass
n = 420; b = 4; A_correct = [ 1 1 1 420 ; 1 1 2 210 ; 1 1 3 140 ; 1 1 4 105 ; 1 1 5 84 ; 1 1 6 70 ; 1 1 7 60 ; 1 1 10 42 ; 1 1 12 35 ; 1 1 14 30 ; 1 1 15 28 ; 1 1 20 21 ; 1 2 2 105 ; 1 2 3 70 ; 1 2 5 42 ; 1 2 6 35 ; 1 2 7 30 ; 1 2 10 21 ; 1 2 14 15 ; 1 3 4 35 ; 1 3 5 28 ; 1 3 7 20 ; 1 3 10 14 ; 1 4 5 21 ; 1 4 7 15 ; 1 5 6 14 ; 1 5 7 12 ; 1 6 7 10 ; 2 2 3 35 ; 2 2 5 21 ; 2 2 7 15 ; 2 3 5 14 ; 2 3 7 10 ; 2 5 6 7 ; 3 4 5 7 ]; assert(isequal(LtdFactor(n,b),A_correct))

5   Pass
n = 2025; b = 3; A_correct = [ 1 1 2025 ; 1 3 675 ; 1 5 405 ; 1 9 225 ; 1 15 135 ; 1 25 81 ; 1 27 75 ; 1 45 45 ; 3 3 225 ; 3 5 135 ; 3 9 75 ; 3 15 45 ; 3 25 27 ; 5 5 81 ; 5 9 45 ; 5 15 27 ; 9 9 25 ; 9 15 15 ]; assert(isequal(LtdFactor(n,b),A_correct))

6   Pass
n = 210; b = 4; A_correct = [ 1 1 1 210 ; 1 1 2 105 ; 1 1 3 70 ; 1 1 5 42 ; 1 1 6 35 ; 1 1 7 30 ; 1 1 10 21 ; 1 1 14 15 ; 1 2 3 35 ; 1 2 5 21 ; 1 2 7 15 ; 1 3 5 14 ; 1 3 7 10 ; 1 5 6 7 ; 2 3 5 7 ]; assert(isequal(LtdFactor(n,b),A_correct))

### Community Treasure Hunt

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

Start Hunting!