Historical context
The great swiss mathematician Leonhard Euler found the formula
to give some prime numbers.
Problem statement
For a given integer m, m >= 41, list the Euler prime numbers less or equal to m in a vector ep. Also compute their frequency / ratio f compare to all the primes in the same range. If m is not a positive integer greater or equal to 41, your function should return ep = [] and f = 0.
Examples (check the tests for more)
- If m = 41 then ep = 41 and f = 1 since 41 = P(0) and it is the only prime number m greater or equal and less or equal to 41;
- If m = 100 then ep = [41, 43, 47, 53, 61, 71, 83, 97] and f = 8/13 since 41 = P(0), 43 = P(1), 47 = P(2), 53 = P(3), 61 = P(4), 71 = P(5), 83 = P(6), and 97 = P(7), and in total there are 13 prime numbers in the range [41; 100] ;
- If m = 19 then ep = [] and f = 0;
Tip
n is less or equal to 107 here.
Fobidden functions
- regexp
- str2num
- assignin
See also
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers23
Suggested Problems
-
23 Solvers
More from this Author42
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Thanks for the cool problems. Keep 'em coming!
Thank you Christian for your nice solutions :-) I used a variation of one of them here for my first solution ;-)