# Random Numbers

**URL:** <https://forum.kirupa.com/t/random-numbers/193013>\
**Category:** Uncategorized\
**Created:** [July 3, 2006, 5:10pm UTC](https://forum.kirupa.com/t/random-numbers/193013 "2006-07-03T17:10:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dr77](https://avatars.discourse-cdn.com/v4/letter/d/ac8455/32.png) [@dr77](https://forum.kirupa.com/u/dr77)\
**Post date:** [July 3, 2006, 5:10pm UTC](https://forum.kirupa.com/t/random-numbers/193013/1 "2006-07-03T17:10:25Z")

</div>

Hello all…

I need to be able to select a random number between 1 and 200… however, I don’t want the number to be selected more than once…

I found this code:

```auto

var minNum:Number = 1;
var maxNum:Number = 200;
var numbers:Array = new Array();
var count:Number = 0;
for (i=minNum; i<=maxNum; i++) {
    numbers[i-1] = i;
}
numbers.sort(shuffle);
this.onMouseDown = function():Void {
    trace(getNum());
};
function shuffle():Number {
    return Math.floor(Math.random()*3)-1;
}
function getNum():Number {
    if (numbers[count] == numbers[numbers.length-1]) {
        numbers.sort(shuffle);
        count = 0;
    }
    return numbers[count++];
}

```

However, this returns a whole array rather a single number.

How do I get at the first number in this array?

I am making a quiz game and want to return a random number (number) which displays a question using an ‘if’ statement: if number == 1{ etc.

I don’t want the same question to be displayed for the remainder of the game.

I hope that this all makes sense…

Cheers for any help…

David
