Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I am trying to get a set of random integers for which I used the function RandomInteger[{1, 50}, 5]. That way, however, there is the chance to get doubles such as {46, 7, 9, 39, 39}. How do I avoid numbers being drawn twice?

Thank you very much for your help


share|improve this question

marked as duplicate by halirutan, Sjoerd C. de Vries, Oleksandr R., Artes, Kuba Sep 4 '13 at 21:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 9 down vote accepted

What you are searching is the function RandomSample

RandomSample[Range[50], 5]
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.