Well, try all numbers from D to 1,000,000. I was able to write a program that calculates this in under 20 seconds.
BestPi: 3.141592653588651 3126535/995207
I used one loop that went from D equals 1 to 1,000,000, the interior loop is where it gets tricky. Like you said, the ratio of N/D has to be between 3 and 4...
3 < N/D < 4
3*D < N < 4*D
That's all you get without posting your code.
-Fredric