From: matt@... (matt neuburg) Date: 2007-01-07T03:45:13+09:00 Subject: Re: HOW-TO produce random numbers within a range? Ruby N00bie wrote: > Hello, > Thanks for reading this. > I am very new to Ruby and have been learning using a tutorial at > http://pine.fm/LearnToProgram/ > by Chris (thanks Chris) > After searching fairly thoroughly in forums and tutorials I found no > answer to my problem. > I have come to a point where i need to generate a random number within a > range. > > I have learnt that rand(100) produces random numbers from 0 to 99 but i > need to know how to set a minimum for the random number. Suppose the range is 50-99. Generate a random number between 0 and 50, and add 50 to the result. m. -- matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/ Tiger - http://www.takecontrolbooks.com/tiger-customizing.html AppleScript - http://www.amazon.com/gp/product/0596102119 Read TidBITS! It's free and smart. http://www.tidbits.com