Problem 2910. Mersenne Primes vs. All Primes
Solution Stats
Problem Comments
-
1 Comment
Hello Grant,
I don't know if it's a lot of work but it could be a good idea to add a Prime Numbers group 2 with more difficult problems. I think about beautiful Ned's problems (primes ladders, Longest prime diagonal, Twins in a window ...).
Solution Comments
-
1 Comment
Nice one. I found a solution of size 127. And I have the impression it's already quite condensed. It's a mystery to me how one can write a solution of size 26. Can anybody give me a hint on how to do so?
-
2 Comments
test cases are wrong.
please be more serious to accept problems.
it doesn't suit mathworks:(
@Ozer Eroglu
Test cases have been verified and they are indeed correct. What makes you think so that they are wrong?
-
1 Comment
Does all the leading solutions with the size below 10, use this ? Nice idea, but this doesn't improve the problem solving skills.
-
6 Comments
My logic is right but test cases are very hude numbers.... failed to evaluate...
You need to learn to avoid loops. You can use isprime on an array. In any case, your logic is wrong. You never test that b is prime.
As Guillaume pointed out, this solution doesn't test if the numbers in b are Mersenne primes, simply if they're less than 2^n-1, which is not the right criterion. Further, you concatenate the index of the loop (j, which goes from 1 to 1...), rather than a Mersenne prime to b.
Also, this problem is designed, as many of James's problems are, to fail by timeout unless vectorized solutions are used.
i have corrected the logic but plz can u tell me smthing about vectorized solutions...
u can also mail me on anupamagarw@gmail.com
http://nl.mathworks.com/help/matlab/matlab_prog/vectorization.html
some tips: http://nl.mathworks.com/help/matlab/matlab_prog/techniques-for-improving-performance.html
Problem Recent Solvers364
Suggested Problems
-
Swap the first and last columns
17148 Solvers
-
2000 Solvers
-
1143 Solvers
-
927 Solvers
-
6791 Solvers
More from this Author139
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!