Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Limited random numbers
Message
From
15/05/2007 09:41:22
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01225489
Message ID:
01225509
Views:
31
>Is it possible to return numbers from 1 to 10,000 in a aleatory way ?

If all you want is a random number between 1 an 10,000, then
Rand(-1)
? INT(RAND()* 10000) + 1
but if you want all the numbers from 1 to 10000 in a random order, then maybe something like this,
LOCAL ARRAY laNums[10000]
LOCAL x, y
x = 10000
FOR y = 1 TO x
  laNums[y] = y
ENDFOR

RAND(-1)
DO WHILE x > 0
  y = INT(RAND()*x) + 1
  ? laNums[y]
  laNums[y] = laNums[x]
  x = x - 1
ENDDO
Previous
Reply
Map
View

Click here to load this message in the networking platform