summaryrefslogtreecommitdiff
path: root/src/node_modules/chance/docs/basics/natural.md
blob: 21273415f70fc8836774e6f6f460f0055914074a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# natural

```js
// usage
chance.natural()
chance.natural({ min: 1, max: 20 })
```

Return a natural number.

_range: 0 to 9007199254740991_

```js
  chance.natural();
  => 125019392395
```

Can optionally provide min and max.

```js
chance.natural({min: 1, max: 20});
=> 14
```

Can optionally provide numbers you wish to exclude.

```js
chance.natural({min: 1, max: 5, exclude: [1, 3]});
=> 2
```

These are inclusive, so they are included in the range. This means
```chance.natural({min: 1, max: 3});``` would return either 1, 2, or 3 or:

```js
// Specific case
1 <= random number <= 3

// General case
min <= random number <= max
```


[Natural Number on Wikipedia][natural]

[natural]: https://en.wikipedia.org/wiki/Natural_number