Random numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|BASIC}}: QuickBASIC headered.)
Line 158: Line 158:


=={{header|BASIC}}==
=={{header|BASIC}}==
{{works with|QuickBasic|4.5}}
RANDOMIZE TIMER 'seeds random number generator with the system time
pi = 3.141592653589793#
DIM a(1 TO 1000) AS DOUBLE
CLS
FOR i = 1 TO 1000
a(i) = 1 + SQR(-2 * LOG(RND)) * COS(2 * pi * RND)
NEXT i

==={{header|Applesoft BASIC}}===
==={{header|Applesoft BASIC}}===
The [[Random_numbers#Commodore_BASIC|Commodore BASIC]] code works in Applesoft BASIC.
The [[Random_numbers#Commodore_BASIC|Commodore BASIC]] code works in Applesoft BASIC.
Line 427: Line 418:
a(i) = 1 + 0.5 * RandomNormal()
a(i) = 1 + 0.5 * RandomNormal()
Next</syntaxhighlight>
Next</syntaxhighlight>

==={{header|QuickBASIC}}===
{{works with|QuickBasic|4.5}}
<syntaxhighlight lang="qbasic">
RANDOMIZE TIMER 'seeds random number generator with the system time
pi = 3.141592653589793#
DIM a(1 TO 1000) AS DOUBLE
CLS
FOR i = 1 TO 1000
a(i) = 1 + SQR(-2 * LOG(RND)) * COS(2 * pi * RND)
NEXT i
</syntaxhighlight>


==={{header|Run BASIC}}===
==={{header|Run BASIC}}===