From: Brian Candler Date: 2010-09-07T16:52:44+09:00 Subject: Re: Dice Roller 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/.