34 lines
744 B
Plaintext
34 lines
744 B
Plaintext
' version 23-10-2016
|
|
' compile with: fbc -s console
|
|
|
|
Randomize Timer 'seed the random function
|
|
|
|
Dim As Double x, y, pi, error_
|
|
Dim As UInteger m = 10, n, n_start, n_stop = m, p
|
|
|
|
Print
|
|
Print " Mumber of throws Ratio (Pi) Error"
|
|
Print
|
|
|
|
Do
|
|
For n = n_start To n_stop -1
|
|
x = Rnd
|
|
y = Rnd
|
|
If (x * x + y * y) <= 1 Then p = p +1
|
|
Next
|
|
Print Using " ############, "; m ;
|
|
pi = p * 4 / m
|
|
error_ = 3.141592653589793238462643383280 - pi
|
|
Print RTrim(Str(pi),"0");Tab(35); Using "##.#############"; error_
|
|
m = m * 10
|
|
n_start = n_stop
|
|
n_stop = m
|
|
Loop Until m > 1000000000 ' 1,000,000,000
|
|
|
|
|
|
' empty keyboard buffer
|
|
While Inkey <> "" : Wend
|
|
Print : Print "hit any key to end program"
|
|
Sleep
|
|
End
|