Guest User

Untitled

a guest
Sep 19th, 2010
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.43 KB | None | 0 0
  1. Throw darts at a square of size 1. Count those that land in an inscribed
  2. circle of radius 1/2 and center (1/2, 1/2).  The area of the circle is
  3. pi/4 and the areas of the square is one so the ratio of the hits in the circle
  4. to the total number of trials is pi/4/1 which is pi/4.  Multiply that ratio by
  5. 4 to get an estimate of pi.  Use random numbers to throw darts. The rand
  6. function returns arandom number between 0.0 and 1.0.
Add Comment
Please, Sign In to add comment