Cody

# Problem 230. Project Euler: Problem 1, Multiples of 3 and 5

Solution 737816

Submitted on 17 Sep 2015
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   Fail
%% x = 1000; y_correct = 233168; assert(isequal(euler001(x),y_correct))

c = [] j = 1 c = 3 j = 2 c = 3 5 j = 3 c = 3 5 6 j = 4 c = 3 5 6 9 j = 5 c = 3 5 6 9 10 j = 6 c = 3 5 6 9 10 12 j = 7 c = 3 5 6 9 10 12 15 j = 8 c = 3 5 6 9 10 12 15 18 j = 9 c = 3 5 6 9 10 12 15 18 20 j = 10 c = 3 5 6 9 10 12 15 18 20 21 j = 11 c = 3 5 6 9 10 12 15 18 20 21 24 j = 12 c = 3 5 6 9 10 12 15 18 20 21 24 25 j = 13 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 j = 14 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 j = 15 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 j = 16 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 j = 17 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 j = 18 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 j = 19 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 j = 20 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 j = 21 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 j = 22 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 j = 23 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 j = 24 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 j = 25 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 j = 26 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 j = 27 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 j = 28 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 j = 29 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 j = 30 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Column 30 65 j = 31 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 31 65 66 j = 32 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 32 65 66 69 j = 33 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 33 65 66 69 70 j = 34 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 34 65 66 69 70 72 j = 35 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 35 65 66 69 70 72 75 j = 36 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 36 65 66 69 70 72 75 78 j = 37 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 37 65 66 69 70 72 75 78 80 j = 38 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 38 65 66 69 70 72 75 78 80 81 j = 39 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 39 65 66 69 70 72 75 78 80 81 84 j = 40 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 40 65 66 69 70 72 75 78 80 81 84 85 j = 41 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 41 65 66 69 70 72 75 78 80 81 84 85 87 j = 42 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 42 65 66 69 70 72 75 78 80 81 84 85 87 90 j = 43 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 43 65 66 69 70 72 75 78 80 81 84 85 87 90 93 j = 44 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 44 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 j = 45 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 45 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 j = 46 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 46 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 j = 47 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 47 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 j = 48 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 48 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 102 j = 49 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 49 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 102 105 j = 50 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 50 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 102 105 108 j = 51 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 51 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 102 105 108 110 j = 52 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 ...

Assertion failed.

2   Fail
%% x = 4000; y_correct = 3732668; assert(isequal(euler001(x),y_correct))

c = [] j = 1 c = 3 j = 2 c = 3 5 j = 3 c = 3 5 6 j = 4 c = 3 5 6 9 j = 5 c = 3 5 6 9 10 j = 6 c = 3 5 6 9 10 12 j = 7 c = 3 5 6 9 10 12 15 j = 8 c = 3 5 6 9 10 12 15 18 j = 9 c = 3 5 6 9 10 12 15 18 20 j = 10 c = 3 5 6 9 10 12 15 18 20 21 j = 11 c = 3 5 6 9 10 12 15 18 20 21 24 j = 12 c = 3 5 6 9 10 12 15 18 20 21 24 25 j = 13 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 j = 14 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 j = 15 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 j = 16 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 j = 17 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 j = 18 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 j = 19 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 j = 20 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 j = 21 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 j = 22 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 j = 23 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 j = 24 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 j = 25 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 j = 26 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 j = 27 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 j = 28 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 j = 29 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 j = 30 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Column 30 65 j = 31 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 31 65 66 j = 32 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 32 65 66 69 j = 33 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 33 65 66 69 70 j = 34 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 34 65 66 69 70 72 j = 35 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 35 65 66 69 70 72 75 j = 36 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 36 65 66 69 70 72 75 78 j = 37 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 37 65 66 69 70 72 75 78 80 j = 38 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 38 65 66 69 70 72 75 78 80 81 j = 39 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 39 65 66 69 70 72 75 78 80 81 84 j = 40 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 40 65 66 69 70 72 75 78 80 81 84 85 j = 41 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 41 65 66 69 70 72 75 78 80 81 84 85 87 j = 42 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 42 65 66 69 70 72 75 78 80 81 84 85 87 90 j = 43 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 43 65 66 69 70 72 75 78 80 81 84 85 87 90 93 j = 44 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 44 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 j = 45 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 45 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 j = 46 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 46 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 j = 47 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 47 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 j = 48 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 48 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 102 j = 49 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 49 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 102 105 j = 50 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 50 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 102 105 108 j = 51 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 51 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 102 105 108 110 j = 52 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 ...

Assertion failed.

3   Fail
%% x = 2340; y_correct = 1276470; assert(isequal(euler001(x),y_correct))

c = [] j = 1 c = 3 j = 2 c = 3 5 j = 3 c = 3 5 6 j = 4 c = 3 5 6 9 j = 5 c = 3 5 6 9 10 j = 6 c = 3 5 6 9 10 12 j = 7 c = 3 5 6 9 10 12 15 j = 8 c = 3 5 6 9 10 12 15 18 j = 9 c = 3 5 6 9 10 12 15 18 20 j = 10 c = 3 5 6 9 10 12 15 18 20 21 j = 11 c = 3 5 6 9 10 12 15 18 20 21 24 j = 12 c = 3 5 6 9 10 12 15 18 20 21 24 25 j = 13 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 j = 14 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 j = 15 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 j = 16 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 j = 17 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 j = 18 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 j = 19 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 j = 20 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 j = 21 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 j = 22 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 j = 23 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 j = 24 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 j = 25 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 j = 26 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 j = 27 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 j = 28 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 j = 29 c = 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 j = 30 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Column 30 65 j = 31 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 31 65 66 j = 32 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 32 65 66 69 j = 33 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 33 65 66 69 70 j = 34 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 34 65 66 69 70 72 j = 35 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 35 65 66 69 70 72 75 j = 36 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 36 65 66 69 70 72 75 78 j = 37 c = Columns 1 through 29 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60 63 Columns 30 through 37 65 66 69 70 72 75 78 80 j = 38 c = Columns 1 through 29 3 5 6 9 10 12 15 18

Assertion failed.

### Community Treasure Hunt

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

Start Hunting!