Re: TI-85 Programming Question


[Prev][Next][Index][Thread]

Re: TI-85 Programming Question



excel98@norfolk.infi.net wrote:
>
> Can anyone explain to me how to use the rand function. I simply want it to
> randomly output a number from one to ten. Or randomly output a variable.
> Can someone help me out with this.


You cannot randomly output a variable.. but this will give you a random
number between 1 and 10:


int 10rand+1


it would more correctly be written "int (10*rand+1)" but the calculator
doesn't care.. the first one is shorter (better).


The rand function alone returns a number between 0.00000... and
0.9999...  you multiply it by 10 to move the decimal to the tens place
thus giving from 0.000... to 9.000... add one to make make it 1.000...
to 10.000.. and use the int function to get a whole number answer.
Hope this answers your question.




                                            Steve


equiman@koan.com


References: