Пример #1
0
 protected void loadLogs(DoubleArrayList to, int last) {
   double logF = 0.;
   int i = 1;
   if (to.size() == 0) { // factorial 0!=1, 1!=1
     to.add(logF);
   } else {
     logF = to.last();
     i = to.size();
   }
   for (; i <= last; i++) {
     logF += Math.log(i);
     to.add(logF);
   }
 }
Пример #2
0
 public double calc(int n) {
   if (n >= SAVED_LOGS.size()) {
     loadLogs(SAVED_LOGS, n + STEP_FORWARD);
   }
   return SAVED_LOGS.get(n);
 }