Given two integers x and n, with
, find the sum of all positive integers below x, that are multiples of any of the integers from 2 up to n.
For example, for
and
, the sum of the multiples of 2, 3, 4 or 5 is:
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers2
Suggested Problems
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15780 Solvers
-
Maximum running product for a string of numbers
2253 Solvers
-
07 - Common functions and indexing 4
422 Solvers
-
290 Solvers
-
Matlab Basics - Set unwanted parts of a vector to zero
261 Solvers
More from this Author116
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Hi David,
I avoided exceeding 'flintmax', minimized multiplication, division and conditional statements. For small n's, like in test 7, | only used a simple sieving algorithm. I also checked my solution with Elixir, and Java and I still get the same result for test 7.
I initially did a sieving algorithm, but it was not efficient enough for large n. I did not consider splitting with two different algorithms.