Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Electricity440 on April 18, 2013, 08:40:51 pm

Title: Random Number
Post by: Electricity440 on April 18, 2013, 08:40:51 pm
How can I generate a random integer from 0 to 36 and store it to a variable in axe?  ???
Title: Re: Random Number
Post by: Builderboy on April 18, 2013, 09:02:03 pm
The command 'rand' generates a random number from 0 to 65535.  To restrict that range to a smaller range, you can use the modular arithmetic operator ^ like so: rand^37.  This divides the random number by 37 and returns the remainder.  By the nature of the remainder, its range is from 0 to N-1 when you divide by N, so this function returns your desired number from 0 to 36. 
Title: Re: Random Number
Post by: Electricity440 on April 18, 2013, 09:37:20 pm
 ok. thanks :hyper: