Cody

# Problem 46600. Generate a list of composite numbers

Solution 2979115

Submitted on 22 Sep 2020 by Tim
• Size: 15
• This is the leading solution.
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 = 10; c_correct = [4 6 8 9 10]; assert(isequal(composites(n),c_correct))

2   Pass
n = 31; c_correct = [4 6 8 9 10 12 14 15 16 18 20 21 22 24 25 26 27 28 30]; assert(isequal(composites(n),c_correct))

3   Pass
n = 500; c = composites(n); len_correct = 404; c_correct80 = [110 207 303 399 495]; assert(isequal(length(c),len_correct) && isequal(c(80:80:end),c_correct80))

4   Pass
n = 50011; c = composites(n); len_correct = 44877; c_correct8900 = [10146 20070 29942 39782 49594]; assert(isequal(length(c),len_correct) && isequal(c(8900:8900:end),c_correct8900))

5   Pass
n = 3628800; c = composites(n); len_correct = 3370110; c_correct670000 = [728682 1450680 2170682 2889408 3607220]; assert(isequal(length(c),len_correct) && isequal(c(670000:670000:end),c_correct670000))

### Community Treasure Hunt

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

Start Hunting!