# Random number with uneven odds

**URL:** <https://forum.kirupa.com/t/random-number-with-uneven-odds/307994>\
**Category:** Uncategorized\
**Created:** [April 14, 2010, 6:05pm UTC](https://forum.kirupa.com/t/random-number-with-uneven-odds/307994 "2010-04-14T18:05:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amaze](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@amaze](https://forum.kirupa.com/u/amaze)\
**Post date:** [April 14, 2010, 6:05pm UTC](https://forum.kirupa.com/t/random-number-with-uneven-odds/307994/1 "2010-04-14T18:05:10Z")

</div>

Hi all!

I want to get a random integer between 0 and 7 and I’ve used the following:

```auto
Math.round(Math.random()*7)

```

The thing is that I want some numbers to appear more times than others.  
Let’s say that I have a loop that runs 100 times. I want:  
0 appear 28 times  
1 appear 28 times  
2 appear 19 times  
3 appear 14 times  
4 appear 6 times  
5 appear 3 times  
6 appear 1 times  
7 appear 1 times

How is this possible?

Thanks
