mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
style fix
This commit is contained in:
parent
126bfbff6b
commit
45fde8b348
@ -145,7 +145,6 @@ function factory (type, config, load, typed) {
|
||||
* @returns {BigNumber} Returns the factorial of n
|
||||
*/
|
||||
|
||||
|
||||
function bigFactorial (n) {
|
||||
if (n.isZero()) {
|
||||
return new type.BigNumber(1) // 0! is per definition 1
|
||||
|
||||
@ -32,9 +32,7 @@ function factory (type, config, load, typed) {
|
||||
*/
|
||||
const permutations = typed('permutations', {
|
||||
'number | BigNumber': factorial,
|
||||
|
||||
'number, number': function (n, k) {
|
||||
|
||||
if (!isInteger(n) || n < 0) {
|
||||
throw new TypeError('Positive integer value expected in function permutations')
|
||||
}
|
||||
@ -44,7 +42,6 @@ function factory (type, config, load, typed) {
|
||||
if (k > n) {
|
||||
throw new TypeError('second argument k must be less than or equal to first argument n')
|
||||
}
|
||||
|
||||
// Permute n objects, k at a time
|
||||
return product((n - k) + 1, n)
|
||||
},
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
|
||||
function product (i, n) {
|
||||
let half
|
||||
if (n < i) {
|
||||
return 1
|
||||
}
|
||||
if (n === i) {
|
||||
return n
|
||||
}
|
||||
half = ((n + i) / 2 ) | 0
|
||||
return product(i, half) * product(half + 1, n)
|
||||
let half
|
||||
if (n < i) {
|
||||
return 1
|
||||
}
|
||||
if (n === i) {
|
||||
return n
|
||||
}
|
||||
half = ((n + i) / 2) | 0
|
||||
return product(i, half) * product(half + 1, n)
|
||||
}
|
||||
|
||||
module.exports = product
|
||||
module.exports = product
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user