# BlitzMax Docs -> 2D - A-Z -> R -> Rand

# Rand( min_value,max_value=1 )

### Returns:

A random integer in the range min (inclusive) to max (inclusive)### Description:

Generate random integerThe optional parameter allows you to use Rand in 2 ways:

Format | Result |

&Rand(x) | Random integer in the range 1 to x (inclusive) |

&Rand(x,y) | Random integer in the range x to y (inclusive) |

### Example:

' Rand.bmx ' Toss a pair of dice. Result is in the range 1+1 to 6+6. ' Count how many times each result appears. Local count[13] For n = 1 To 3600 toss = Rand(1,6) + Rand(1,6) count[toss] :+ 1 Next For toss = 2 To 12 Print LSet(toss, 5)+count[toss] Next

Comments

None.

BlitzMax Manual Forum

Blitz3D Equivalent Command