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