# How to generate a serial of random numbers

**URL:** <https://www.ruby-forum.com/t/how-to-generate-a-serial-of-random-numbers/125998>\
**Category:** Rails\
**Created:** [January 14, 2008, 3:57pm UTC](https://www.ruby-forum.com/t/how-to-generate-a-serial-of-random-numbers/125998 "2008-01-14T15:57:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [January 14, 2008, 3:57pm UTC](https://www.ruby-forum.com/t/how-to-generate-a-serial-of-random-numbers/125998/1 "2008-01-14T15:57:09Z")

</div>

Hi all,

I want to generate a serial of 5 random numbers based on the size of an  
array(let say the size of array is 100).  
Here are the rules:1) 5 random numbers are different 2) Once they are  
generated they can’t appear in the next round of random numbers. What is  
the better way to do this? Now what I think of is to remove the items  
corresponding to the random number from the previouse array and  
eventually my array is smaller and smaller. Any other idea?

Thanks,

Li
