# Can random(5) output the number 5?

**URL:** https://discourse.processing.org/t/can-random-5-output-the-number-5/29241
**Category:** Beginners
**Created:** [April 9, 2021, 8:20am UTC](https://discourse.processing.org/t/can-random-5-output-the-number-5/29241 "2021-04-09T08:20:29Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)
#### Post date: [April 9, 2021, 11:57am UTC](https://discourse.processing.org/t/can-random-5-output-the-number-5/29241/10 "2021-04-09T11:57:59Z")

</div>

So, given the code from [here](https://discourse.processing.org/t/can-random-5-output-the-number-5/29241/7), these two lines would be equivalent:

- `println(rand.nextInt(6));`
- `println(floor(random(6));`

On another note concerning the use of random numbers, something many of us may have often noticed are statements such as this:

```auto
int r = random(255);
int r = random(255);
int r = random(255);
fill(r, g, b);

```

That is unfortunate, since it misses the opportunity to achieve a full range of colors, leaving out `255` as a possible resulting intensity value. This would be better:

```auto
int r = random(256);
int r = random(256);
int r = random(256);
fill(r, g, b);

```

Alternatively, we could do something like this:

```auto
int r = rand.nextInt(256);
int r = rand.nextInt(256);
int r = rand.nextInt(256);
fill(r, g, b);

```

See the discussion [A newbie needs help](https://discourse.processing.org/t/a-newbie-needs-help/28832).

---

_[View the full topic](https://discourse.processing.org/t/can-random-5-output-the-number-5/29241)._
