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

Re: Interesting one-line BASIC program



On Apr 1, 2:45 am, "Michael J. Mahon" <mjma...@aol.com> wrote:
> As you'll see if you Ctl-C out of the loop and examine "I" when
> the display stops changing, it takes less than 20000 iterations.

Or one can count it exactly below - emulator recommended! ;-)

10 HGR
20 FOR I = 1 TO 40000
30 OFFSET = 8192 + 8192 * RND(1)
40 IF PEEK(OFFSET) = 0 THEN PERIOD = I
50 POKE OFFSET, 255
60 REM OR TO VISUALISE ENTROPY USE ...
70 REM POKE OFFSET, PEEK(OFFSET) + 1
80 NEXT I
90 PRINT PERIOD

The period seems to be around 38,000 depending on the seed.
(The large variation is strange - I'd pry if I had time.)

Oh, I came across this quite a while back, and again now:
A Better Random Number Generator for Apple's Floating Point BASIC
http://www.kaner.com/pdfs/random.pdf

Cheers,
Nick.