Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As @Turtle answered, you problem doesn't have a solution. @KandadaBoggu and @bta solution gives you random numbers is some ranges which are or are not random. You get clusters of numbers.</p> <p>But I don't know why you care about double occurence of the same number. If <code>(0..99**99)</code> is your range, then if you could generate 10^10 random numbers per second (if you have a 3 GHz processor and about 4 cores on which you generate one random number per CPU cycle - which is imposible, and ruby will even slow it down a lot), then it would take about <strong>10^180 years</strong> to exhaust all the numbers. You have also probability about 10^-180 that two identical numbers will be generated during a whole year. Our universe has probably about 10^9 years, so if your computer could start calculation when the time began, then you would have probability about 10^-170 that two identical numbers were generated. In the other words - <strong>practicaly it is imposible</strong> and you don't have to care about it. </p> <p>Even if you would use Jaguar (top 1 from <a href="http://www.top500.org" rel="nofollow noreferrer">www.top500.org</a> supercomputers) with only this one task, you still need 10^174 years to get all numbers. </p> <p>If you don't belive me, try</p> <pre><code>tried = {} # store previous attempts bigint = 99**99 bigint.times { x = rand(bigint) puts "Oh, no!" if tried[x] tried[x] = true } </code></pre> <p>I'll buy you a beer if you will even once see "Oh, no!" on your screen during your life time :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload