panthrMath/basicFunc/choose.js
function lchoose(n, k) {
      k = Math.round(k);
      if (utils.hasNaN(n, k)) { return NaN; }
      if (k < 0) { return -Infinity; }
      if (k === 0) { return 0; }
      if (k === 1) { return Math.log(Math.abs(n)); }
      if (n < 0) { return lchoose(-n + k - 1, k); }
      if (n === Math.round(n)) {
         if (n < k) { return -Infinity; }
         if (n - k < 2) { return lchoose(n, n - k); }

         return lfastchoose(n, k);
      }
      if (n < k - 1) { return lfastchoose2(n, k); }

      return lfastchoose(n, k);
   }
function lchoose(n, k) {
      k = Math.round(k);
      if (utils.hasNaN(n, k)) { return NaN; }
      if (k < 0) { return -Infinity; }
      if (k === 0) { return 0; }
      if (k === 1) { return Math.log(Math.abs(n)); }
      if (n < 0) { return lchoose(-n + k - 1, k); }
      if (n === Math.round(n)) {
         if (n < k) { return -Infinity; }
         if (n - k < 2) { return lchoose(n, n - k); }

         return lfastchoose(n, k);
      }
      if (n < k - 1) { return lfastchoose2(n, k); }

      return lfastchoose(n, k);
   }
function lchoose ( n , k ) { k = Math . round ( k ) ; if ( utils . hasNaN ( n , k ) ) { return NaN ; } if ( k < 0 ) { return - Infinity ; } if ( k === 0 ) { return 0 ; } if ( k === 1 ) { return Math . log ( Math . abs ( n ) ) ; } if ( n < 0 ) { return lchoose ( - n + k - 1 , k ) ; } if ( n === Math . round ( n ) ) { if ( n < k ) { return - Infinity ; } if ( n - k < 2 ) { return lchoose ( n , n - k ) ; } return lfastchoose ( n , k ) ; } if ( n < k - 1 ) { return lfastchoose2 ( n , k ) ; } return lfastchoose ( n , k ) ; }
Computes the logarithm of the absolute value of the binomial coefficient.
Valid for any real n and for integer k.
k will be rounded if it is not an integer.
Computes the logarithm of the absolute value of the binomial coefficient . Valid for any real n and for integer k . k will be rounded if it is not an integer .