# Calculating pi to an arbitrary number of digits

Here is a really usefull helper class that you can use to calculate PI to an arbitrary number of (string) digits: sourcecode download. Note that you do need the JDK 1.5 for it.

```import java.util.*;

public class pi
{
public int execute(int... args)
{
o [] oo = {
new o() { public void _() {
execute(21,9,15,17,9,16,20,9,28,9,26);
} }, new o() { public void _() {
execute(21,9,15,17,9,16,20,17,9,29,9,25,20,9,28,17,
9,15,17,9,25,16,37,9,23,9,15,17,9,28,9,25,22,9,18,30,
28,9,23,12,17,9,12,17,9,15,17,9,28,9,25,22,9,18,30,
15,17,9,28,9,25,22,9,18,25,18,29,9,23,15,17,9,21,9,
16,29,17,9,26);
} }, new o() { public void _() {
execute(14,9,31,9,23,22,17,9,22,9,16,22,9,23);
} },  new o() { public void _() {
s.append(O[1]);
} }, new o() { public void _() {
execute();
} }, new o() { public void _() {
execute(9,9,18,28,9,23,22,9,32,9,23,
24,31,17,9,22,9,23,27,17,9,
28,17,9,29,9,30,16,31,9,23,
28,17,9,28,17,9,29,9,30,29,
9,25,18,27,9,23,12,9,28,9,
31,17,9,29,9,18,20,9,11,15,
9,12,9,14,17,9,11,14,17,9,
22,9,16,19,9,23);
} }, new o() { public void _() {
execute(14,17,9,10,17,9,18);
} }, new o() { public void _() {
execute(5,13);
} }, new o() { public void _() {
execute(32,17,33,15,17,9,22,9,18,20,9,15,9,23,34);
} }, new o() { public void _() {
O[42+1+O[42]++] = O[11];
} }, new o() { public void _() {
execute(12,9,15,9,16,20);
} }, new o() { public void _() {
execute(20);
O[11] = (O[11] == 0) ? execute(20,33,20) : execute(20,20,33);
} }, new o() { public void _() {
execute(28,9,9,16,20);
} }, new o() { public void _() {
execute(10,9,12,9,6,11);
} }, new o() { public void _() {
execute(10,17,9,9,18,20);
} }, new o() { public void _() {
execute(12,9,22,9,18,20);
} }, new o() { public void _() {
execute(38,39,9);
} }, new o() { public void _() {
O[11] = O[O[11]];
} }, new o() { public void _() {
execute(38,40,9);
} }, new o() { public void _() {
execute(10,17,9,9,18,20);
} }, new o() { public void _() {
O[11] = O[42+1+--O[42]];
} }, new o() { public void _() {
O[11] = execute();
} }, new o() { public void _() {
execute(21,9,9,30,20);
} }, new o() { public void _() {
execute(20);
O[10] = O[11];
execute(20);
O[O[10]] = O[11];
} }, new o() { public void _() {
execute(10,17,9,29,9,25,15,9,30,9,15,9,23,34);
} }, new o() { public void _() {
execute(38,41,9);
} }, new o() { public void _() {
execute(20);
O[10] = O[11];
execute(20);
O[O[11]] = O[10];
} }, new o() { public void _() {
execute(12,9,22,9,16,20);
} }, new o() { public void _() {
execute(22,9,9,16,20);
} }, new o() { public void _() {
execute(12,9,22,9,16,28,9,25,20);
} }, new o() { public void _() {
execute(38,42,9);
} }, new o() { public void _() {
execute(12,9,28,9,16,20);
} }, new o() { public void _() {
execute(15,9,15,9,25,20);
} }, new o() { public void _() {
execute(O[11]);
} }, new o() { public void _() {
execute(35,9,12,9,36,9,11);
} }, new o() { public void _() {
execute(12,9,9,16,20);
} }, new o() { public void _() {
execute(15,17);
} }, new o() { public void _() {
execute(28,9,9,16,20);
} }, new o() { public void _() {
execute(20);
O[8] = O[11];
execute(20);
} }, new o() { public void _() {
O[11] += O[8];
} }, new o() { public void _() {
O[11] -= O[8];
} }, new o() { public void _() {
O[11] *= O[8];
} }, new o() { public void _() {
O[11] /= O[8];
} }, new o() { public void _() {
execute(24,14,9,9,26,13);
} },
};
for (int o : args) oo[o]._(); return 1860;
}

int [] O = null;
interface o { void _(); }
StringBuffer s = null;
public pi(int n)
{
O = new int[n*execute()];
O[7] = n+2;
s = new StringBuffer();
execute(43);
}

public static void main(String[] args)
{
// example: calculate 20 digits of pi
System.out.println(new pi(20).s);
}
}
```