# Questions on how p5.js generates random numbers

**URL:** <https://discourse.processing.org/t/questions-on-how-p5-js-generates-random-numbers/39128>\
**Category:** Beginners\
**Created:** [October 7, 2022, 8:40am UTC](https://discourse.processing.org/t/questions-on-how-p5-js-generates-random-numbers/39128 "2022-10-07T08:40:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![reacttoimpact](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@reacttoimpact](https://discourse.processing.org/u/reacttoimpact)\
**Post date:** [October 7, 2022, 8:40am UTC](https://discourse.processing.org/t/questions-on-how-p5-js-generates-random-numbers/39128/1 "2022-10-07T08:40:45Z")

</div>

Hi all,

How does p5.js generate random numbers?  
What type of PRNG does it use?  
Does it use javascripts random function? If so how does that work?  
Where is the code that generates random numbers?  
is there anything interesting i should know?

Many thanks,  
reacttoimpact

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [October 7, 2022, 10:00am UTC](https://discourse.processing.org/t/questions-on-how-p5-js-generates-random-numbers/39128/2 "2022-10-07T10:00:26Z")

</div>

Hi @reacttoimpact,

here some sources …

Cheers  
— mnse

js random numbers:

> **[How does JavaScript’s Math.random() generate random numbers? | HackerNoon](https://hackernoon.com/how-does-javascripts-math-random-generate-random-numbers-ef0de6a20131)**
>
> Open up your dev tools’ (Mac: cmd + option + i / Windows: ctrl + shift + i), go to the Console, type Math.random() , and hit return.

p5js source:

> <https://github.com/processing/p5.js/blob/main/src/math/random.js>
