generate a random number between 1 and 100 in ruby

To generate a random number between 1 and 100 in Ruby, you can use the rand method and specify a range of 1..100. Here is an example of how to generate a random number:

main.rb
random_num = rand(1..100)
puts random_num
42 chars
3 lines

This will output a random number between 1 and 100 each time this code runs. You can also store this number in a variable or use it in other parts of your program as needed.

gistlibby LogSnag