From: vadivelan K Date: 2010-09-07T18:03:36+09:00 Subject: Re: Dice Roller --0016e6480678fd2779048fa7abba Content-Type: text/plain; charset=ISO-8859-1 Thanks Brian for pointed out this. Yes it will returns the value bw 0 and 4 suits for 5-sided die. We can use this puts "Roll #{n+1}: #{1 + rand(7-1)}" This way we can get the values between 0 to 6 as final result. On Tue, Sep 7, 2010 at 1:22 PM, Brian Candler wrote: > Vadivelan Vaddi wrote: > > By adding the min value to the rand(max-min), we can get random number > > bw the range(min,max). > > > > print "How many dice do you want to roll? " > > num_rolls = gets.to_i > > num_rolls.times do |n| > > puts "Roll #{n+1}: #{1 + rand(6-1)}" > > end > > That's a five-sided die. rand(5) gives a number between 0 and 4 > inclusive. > -- > Posted via http://www.ruby-forum.com/. > > -- regards, vadivelan --0016e6480678fd2779048fa7abba--