Cody

Problem 43754. Lah Numbers

Solution 1545389

Submitted on 31 May 2018 by J. S. Kowontan
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; y_correct = [1,0,0,0,0,0,0,0,0;2,1,0,0,0,0,0,0,0;6,6,1,0,0,0,0,0,0;24,36,12,1,0,0,0,0,0;120,240,120,20,1,0,0,0,0;720,1800,1200,300,30,1,0,0,0;5040,15120,12600,4200,630,42,1,0,0;40320,141120,141120,58800,11760,1176,56,1,0;362880,1451520,1693440,846720,211680,28224,2016,72,1]; assert(isequal(lah(x),y_correct))

ans = 1 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 6 6 1 0 0 0 0 0 0 24 36 12 1 0 0 0 0 0 120 240 120 20 1 0 0 0 0 720 1800 1200 300 30 1 0 0 0 5040 15120 12600 4200 630 42 1 0 0 40320 141120 141120 58800 11760 1176 56 1 0 362880 1451520 1693440 846720 211680 28224 2016 72 1

2   Pass
x = 1; y_correct = [1,0;2,1]; assert(isequal(lah(x),y_correct))

ans = 1 0 2 1

3   Pass
x = 3; y_correct = [1,0,0,0;2,1,0,0;6,6,1,0;24,36,12,1]; assert(isequal(lah(x),y_correct))

ans = 1 0 0 0 2 1 0 0 6 6 1 0 24 36 12 1

4   Pass
x = 10; y_correct = [1,0,0,0,0,0,0,0,0,0,0;2,1,0,0,0,0,0,0,0,0,0;6,6,1,0,0,0,0,0,0,0,0;24,36,12,1,0,0,0,0,0,0,0;120,240,120,20,1,0,0,0,0,0,0;720,1800,1200,300,30,1,0,0,0,0,0;5040,15120,12600,4200,630,42,1,0,0,0,0;40320,141120,141120,58800,11760,1176,56,1,0,0,0;362880,1451520,1693440,846720,211680,28224,2016,72,1,0,0;3628800,16329600,21772800,12700800,3810240,635040,60480,3240,90,1,0;39916800,199584000,299376000,199584000,69854400,13970880,1663200,118800,4950,110,1]; assert(isequal(lah(x),y_correct))

ans = 1 0 0 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 0 0 6 6 1 0 0 0 0 0 0 0 0 24 36 12 1 0 0 0 0 0 0 0 120 240 120 20 1 0 0 0 0 0 0 720 1800 1200 300 30 1 0 0 0 0 0 5040 15120 12600 4200 630 42 1 0 0 0 0 40320 141120 141120 58800 11760 1176 56 1 0 0 0 362880 1451520 1693440 846720 211680 28224 2016 72 1 0 0 3628800 16329600 21772800 12700800 3810240 635040 60480 3240 90 1 0 39916800 199584000 299376000 199584000 69854400 13970880 1663200 118800 4950 110 1

Suggested Problems

More from this Author11

Community Treasure Hunt

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

Start Hunting!