diff --git a/lib/function/combinatorics/composition.js b/lib/function/combinatorics/composition.js index 6f074ee8e..9b34f3a30 100644 --- a/lib/function/combinatorics/composition.js +++ b/lib/function/combinatorics/composition.js @@ -57,7 +57,7 @@ module.exports = function (math) { if (k.gt(n)) { throw new TypeError('k must be less than n in function composition'); } - return math.combinations(n-1,k-1); + return math.combinations(n.minus(1), k.minus(1)); } else { throw new TypeError('Integer values are expected in composition') } diff --git a/test/function/combinatorics/composition.js b/test/function/combinatorics/composition.js index e6e2b7d28..399fa80cb 100644 --- a/test/function/combinatorics/composition.js +++ b/test/function/combinatorics/composition.js @@ -14,6 +14,7 @@ describe('composition', function() { it('should calculate the composition of n items taken k at a time with BigNumbers', function(){ assert.equal(composition(math.bignumber(7), math.bignumber(5)), math.bignumber(15)); assert.equal(composition(math.bignumber(70), math.bignumber(3)), math.bignumber(2346)); + assert.equal(composition(math.bignumber(56), math.bignumber(11)), math.bignumber(29248649430)); }); it('should not work with non-integer and negative input', function() {