Back to Pi, nobody seems to have mentioned the "Dartboard Method":
Assuming we have a floating-point random number generator that returns values < 1.0, we simply iterate with
- N = N + 1
- X = rand() * 2 - 1
- Y = rand() * 2 - 1
- D = sqrt(X*X + Y*Y)
- if (D <= 1.0) B = B + 1
Convergence is well, shall we say, a tad sluggish. But for algorithmic elegance, it's hard to beat!