Sample code for 30+ languages & platforms
Ruby

Generating Random Integer in Range

See more PRNG Examples

Demonstrates how to generate random integers in a specified range.

Chilkat Ruby Downloads

Ruby
require 'chilkat'

success = false

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

success = false

fortuna = Chilkat::CkPrng.new()

# Generate random integers between 12 and 24 inclusive

for i in 0 .. 100
    print fortuna.RandomInt(12,24).to_s() + "\n";
end