private static final double[] PI_TABLE = new double[] {

3.0, 3.1, 3.14, 3.141, 3.1415, 3.14159, 3.141592, ...

};


public static double getPi(int digits) {

if (digits < 0) {

throw new Exception("digits < 0");

}

return PI_TABLE[digits];

}


이러면 O(1)이 됨. 나 진짜 천재인듯 (뿌듯)