in reply to Re: Random numbers generation
in thread Random numbers generation

What do we mean by "between"? Your code works fine, but it includes 250 and excludes 500.

Replies are listed 'Best First'.
Re: Re: Re: Random numbers generation
by blue_cowdawg (Monsignor) on May 21, 2004 at 17:01 UTC

        Your code works fine, but it includes 250 and excludes 500.

    Direct quote from perldoc -f rand:

    Apply "int()" to the value returned by "rand()" if you +want random integers instead of random fractional numbers. +For example, int(rand(10)) returns a random integer between 0 and 9, inclusive.
    With this in mind take a look at my reply and apply a small tweak:
    my @answers=(); push @answers,(int(rand(251))+250) foreach (0..99);
    The sequence int(rand(251)) will now produce integers in the range of 0..250 and when added to 250 will produce 250..500.

Re: Re: Re: Random numbers generation
by pbeckingham (Parson) on May 21, 2004 at 18:21 UTC

    What I meant was that from reading the OP's code, it generates random numbers between 0 and 100, but does it 250 times. The algorithm is backwards.