[Tutor] ** Newbie ** - Fastest random choice from integers 0 to X?

Chris McCormick cmccormick@thestate.com
Thu, 07 Feb 2002 14:21:02 -0500

Hello all,
	I'm sure this is a simple answer, but I wasn't sure what would be fastest.

I have a group of consecutive integers, 0 to X.  Given only the top bound (X), what is the fastest way to produce a random integer, 0 and X inclusive?  My guess is:

	random.randrange( 0, (X+1), 1 )

Is this right?  

Thanks in advance for your help,
Chris McCormick