Cody

Problem 3002. Not square-free number sequence

Solution 2872916

Submitted on 24 Aug 2020 by Raghunadh N
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 = 1:5; arr_corr = [4, 8, 9, 12, 16]; assert(isequal(not_squarefree_seq(n),arr_corr))

ans = 4 8 9 12 16

2   Pass
n = 1:10; arr_corr = [4, 8, 9, 12, 16, 18, 20, 24, 25, 27]; assert(isequal(not_squarefree_seq(n),arr_corr))

ans = 4 8 9 12 16 18 20 24 25 27

3   Pass
n = 3:7; arr_corr = [9 12 16 18 20]; assert(isequal(not_squarefree_seq(n),arr_corr))

ans = 9 12 16 18 20

4   Pass
n = 20:30; arr_corr = [52 54 56 60 63 64 68 72 75 76 80]; assert(isequal(not_squarefree_seq(n),arr_corr))

ans = 52 54 56 60 63 64 68 72 75 76 80

5   Pass
n = 1:62; arr_corr = [4, 8, 9, 12, 16, 18, 20, 24, 25, 27, 28, 32, 36, 40, 44, 45, 48, 49, 50, 52, 54, 56, 60, 63, 64, 68, 72, 75, 76, 80, 81, 84, 88, 90, 92, 96, 98, 99, 100, 104, 108, 112, 116, 117, 120, 121, 124, 125, 126, 128, 132, 135, 136, 140, 144, 147, 148, 150, 152, 153, 156, 160]; assert(isequal(not_squarefree_seq(n),arr_corr))

ans = Columns 1 through 30 4 8 9 12 16 18 20 24 25 27 28 32 36 40 44 45 48 49 50 52 54 56 60 63 64 68 72 75 76 80 Columns 31 through 60 81 84 88 90 92 96 98 99 100 104 108 112 116 117 120 121 124 125 126 128 132 135 136 140 144 147 148 150 152 153 Columns 61 through 62 156 160

6   Pass
i1 = randi(20,1); n = i1:(i1+randi(25,1)); arr_tot = [4, 8, 9, 12, 16, 18, 20, 24, 25, 27, 28, 32, 36, 40, 44, 45, 48, 49, 50, 52, 54, 56, 60, 63, 64, 68, 72, 75, 76, 80, 81, 84, 88, 90, 92, 96, 98, 99, 100, 104, 108, 112, 116, 117, 120, 121, 124, 125, 126, 128, 132, 135, 136, 140, 144, 147, 148, 150, 152, 153, 156, 160]; arr_corr = arr_tot(n); assert(isequal(not_squarefree_seq(n),arr_corr))

ans = 52 54 56 60 63 64 68 72 75 76 80 81 84 88 90 92 96 98

Suggested Problems

More from this Author139

Community Treasure Hunt

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

Start Hunting!