第1个回答 2008-03-17
public class MyTest {
public double getResult(){
double result = 0;
int i = 1;
do{
result += 1.0/getDenominator(i);
i++;
}while(i <= 20);
return result;
}
private int getDenominator(int i){
for(int j = i-1; j >= 1 ; j--){
i *= j;
}
return i;
}
public static void main(String[] args) {
MyTest test = new MyTest();
System.out.println(test.getResult());
}
}