From: Rick DeNatale Date: 2008-06-10T21:17:36+09:00 Subject: Re: Random Number Stuff ------=_Part_34360_13669511.1213100266930 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Mon, Jun 9, 2008 at 9:57 PM, David Stanislaus wrote: > Ok, i guess I kind of understand it but why (20)? shouldn't it be 1950? > rand(i) if i is nonzero, returns a number between 0 and i - 1. (Actually i converted to an integer - 1). So rand(1950) will return a random number between 0 and 1949, which is not what you are looking for. To return a random number between a and b inclusive, you need a + rand(1+b-a) so for a = 1930, b = 1950 1930 + rand(21) which is the sum of 1930 and a random number between 0 and 20, which of course will be a random number between 1930 and 1950. Cappisch? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ ------=_Part_34360_13669511.1213100266930--