Cody

Problem 44696. Sum of unique multiples of 3 and 5

Solution 1591155

Submitted on 25 Jul 2018 by Mohammed Shafiq
  • Size: 10
  • 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 = 15; sm_correct = 60; assert(isequal(sum3and5muls(n),sm_correct))

sum_mult = 60

2   Pass
n = 18; sm_correct = 78; assert(isequal(sum3and5muls(n),sm_correct))

sum_mult = 78

3   Pass
n = (2^2)-1; sm_correct = 3; assert(isequal(sum3and5muls(n),sm_correct))

sum_mult = 3

4   Pass
n = randi(25); sm_correct = sum(3:3:n)+sum(5:5:n)-sum(15:15:n); assert(isequal(sum3and5muls(n),sm_correct))

sum_mult = 60

Suggested Problems

More from this Author29

Community Treasure Hunt

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

Start Hunting!