The test suite could match the problem statement more closely if it would test an input that was also prime. One would expect that if the input is 7, the output would be 2 + 3 + 5 since 7 is not "below" 7?
The code "sum(find((isprime(1:x))))" works well on my own computer,but in cody it keeps says "While evaluating the solution, the server encountered an error caused by long running MATLAB code. Edit the code if needed and then rescore." I don't know why, is the test x=2000000 too large!?
The problem states: "Find the sum of all the primes below the input, N". For the input 11, the largest prime below it is 7. So 2 + 3 +5 + 7 = 17. If x = 12, then the answer should be 28.
3 Comments