May I ask how to choose random prime number in fix interval?
6 views (last 30 days)
Show older comments
loong seow li
on 28 Apr 2016
Commented: loong seow li
on 28 Apr 2016
May I ask how to choose random prime number in fix interval? For example, choose prime number in between 2 to 30...
0 Comments
Accepted Answer
Andrei Bobrov
on 28 Apr 2016
a = 2;
b = 30;
p = primes(b);
p = p(p >= a);
out = p(randperm(numel(p),1));
More Answers (1)
See Also
Categories
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!