Click to See Complete Forum and Search --> : TI-83 calc - random numbers
neil9999
03-09-2004, 02:08 PM
Hi,
On my TI-83, the randInt(A,B,C) function picks C amount of random numbers between A and B. The only problem is the numbers picked can be the same. Is there any way to make sure they're different?
Thanks,
Neil
steelersfan88
03-09-2004, 03:49 PM
not quite sure what the calculator supports
you could loop as you would in most languages while the number == the same as the previous number (and if true, generates a new number) and this would be done for all numbers, but again, whether or not a calculator supports, not quite sure
maybe http://www.ti.com/ has some info. about it
you'll need to do a while loop and map all your values to a list (basically a calculator array). Then have the while loop to see if a number is already on the list before adding the current random number. I did something similar when I made minesweeper for my ti92, shouldn't be too difficult
neil9999
03-09-2004, 04:08 PM
The calculator has its own programming language - I think. It supports while loops. How would I do this is in Javascript, or TI-92, and I'll probably be able to convert it?
Thanks for your replies,
Neil
ti92 went something like this (this is off the top of my head, so no guaruntees it will work):
:0->count
:delvar L1
:While count<10
:rand(50)->temp
:for i,0,dim(L1),1
:if L1[i]=temp then
:goto endofloop
:endIf
:endFor
:temp->L1[count]
:count=count+1
:lbl endofloop
:endWhile
note: ti92 supports multi character variable names, while the ti83 only supports single characters
note 2: -> indicates a press of the STO button
note 3: the random number syntax is slightly different on the 92
note 4: I don't remember if the syntax for a label is lbl or label, so you'll have to fix that for yourself
neil9999
03-10-2004, 11:12 AM
Thanks for that - I'll see if I can adapt it.
Neil