To generate the same sequence, select a negative number and ail
RND
with
this number before beginning to fetch the random numbers. The
following
program prints the first five random numbers for seeds
-l,
-2, -3,
...
-100.
10
FOR
1=-1
Ta
-100
STEP
-1
20
X=RND(1):PR1NT
l
30
FOR
..1=1
TO
5
40
PF::I
tH
RND
( 1 )
50
NEXT
..1:PR1NT:FOR K=0
TO
1000:NEXT
K
6(1
NEXT
l
RUt·~
-1
•
73503~1872
•
35438898:;:
.747932106
.16562769
.62863439
-2
.271819872
.14311354
.511223365
•
:367604656
.148456903
-3
.235981913
.365113894
.905614705
.916307965
.987458745
Note here
that
the
"1"
in RND(l)
on
line
40
can
be
any positive, non-zero
number: it doesn't matter
which
one.
On
line 50, the
PRINT
is
to give a blank line:
the
FOR
K loop
is
ta pause between number sets.
Suppose vou select
-40
as
a seed; your program
might
have statements
like the following:
10
X=RND(-40)
REM
START SEED
20
A=RND(l):
REM
FETCH A
RANDOM
NUMBER
.
150
M~<:=RND(
1)
:
REM
FETCH
At'JOTHER
RAt·mOM
NU~1BER
You probably
don't
have any use for the
seed
value assigned to
X,
but
an
assignment statement
is
the easiest way to include a legitimate reference for
RND
(-argl.
Each time statement 10
is
executed, it
will
restart the random number
sequence at the same beginning.
292