Generates a random number.

rand() or rand(*n*)

**Menu Location**

- Press 2nd MATH to enter the MATH popup menu.
- Press 7 to enter the Probability submenu.
- Press 4 to paste rand(.

This command works on all calculators.

2 bytes

The rand() command generates a random number. It can be used in one of two ways:

- rand() gives a random real number between 0 and 1.
- rand(
*n*) gives a random integer between 1 and*n*.

By adding or multiplying appropriately, you can change these bounds. For example, 10rand() gives a random real number between 0 and 10, and rand(9)-5 gives a random number between -4 and 4.

L'Ecuyer's algorithm is used by TI calculators to generate pseudorandom numbers.

```
:RandSeed 0
:rand()
.943597402492
:rand()
.908318860975
:rand(10)
2
```

# Advanced Uses

Using the RandSeed command makes the random numbers entirely predictable: after setting the random seed to some value, the same random numbers will be returned every time.

# Error Conditions

**260 - Domain error** happens when the maximum number is 10^{14} or greater.