Inspired by Project Euler n°10 (I am quite obviously a fan).
With problem n°250 by Doug, you can find some global methods to compute the sum of all the primes below the input n.
For example, the sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
But how to proceed (in time) with big number and WITHOUT the primes function ?
HINTS: sum(primes(n)) is possible here but why miss the wonderfull Sieve of Eratosthenes ?
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers244
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
53428 Solvers
-
Find the numeric mean of the prime numbers in a matrix.
9161 Solvers
-
Project Euler: Problem 3, Largest prime factor
1819 Solvers
-
Find the sum of the elements in the "second" diagonal
1206 Solvers
-
Implement a bubble sort technique and output the number of swaps required
398 Solvers
More from this Author43
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Be careful, I've implemented the sieve, but not all versions of it are sufficiently fast to handle the biggest numbers in the test suite.
While evaluating the solution, the server encountered an error caused by long running MATLAB code. Edit the code if needed and then submit.