Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Re: Random numbers generation

by blue_cowdawg (Monsignor)
on May 21, 2004 at 17:01 UTC ( [id://355350]=note: print w/replies, xml ) Need Help??


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

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://355350]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-20 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found