It seems you are not getting it (concluded from your variouse comments)...

If you

**don't store**which numbers (of any set you wish your random numbers to come from e.g. 1-50) are already used, you can

**not know**if the number is

**unique**- Can you agree on that?

So your whole "requirenment" "without storing values and checking..." is wrong.

**It can't be done**- this is a pure logical contradiction and has nothing to do with programming in general.

Yes there are algorithms which will make it very

**unlikely**to produce the same number again (e.g. GUIDs).

So a valid solution could be: Pre-Generate a "set" of numbers - like playing cards and pick them randomly. If you try this you have to think about what happens if you "run out" of numbers/cards.

Another (may be inefficient) approach could be just to store all the generated numbers from past calls and check if the new number is contained - then retry if number was used - again what happens if there are no more "free" numbers in range...

So you see, just insisting on a "not so well thought" requirement won't solve your problem. Maybe you tell us what you want to achieve in the end and what is your real problem?

Kind regards

Johannes

What are you actually trying to achieve and why?