Historical context
The polish-american mathematician Stanislaw Ulam found the formula to give some prime numbers not given neither by Euler's formula neither by its own first formula.
Problem statement
For a given integer m, m >= 59, list the Ulam prime numbers less or equal to m in a vector up. 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 59, your function should return up = [] and f = 0.
Examples (check the tests for more)
  • If m = 59 then up = 59 and f = 1 since 59 = P(0) and it is the only prime number m greater or equal and less or equal to 59;
  • If m = 200 then up = [59, 67, 83, 107, 139, 179] and f = 6/30 since 59 = P(0), 67 = P(1), 83 = P(2), 107 = P(3), 139 = P(4), 179 = P(5), and there are in total 30 prime numbers in the range [59; 200] ;
  • If m = 23 then up = [] and f = 0;
Tip
here.
Fobidden functions
  • regexp
  • assignin
  • str2num
See also

Solution Stats

28 Solutions

19 Solvers

Last Solution submitted on Jan 05, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...