dankogai / js-combinatorics

power set, combination, permutation and more in JavaScript
MIT License
742 stars 97 forks source link

Fixes #52 - Infinite loop #54

Closed markus-willems closed 6 years ago

markus-willems commented 6 years ago

Some functions enter an infinite loop if applied with factorial numbers. This PR should fix this.

Specifically, the P function will not leave its loop if n is a number >1 that's a factorial number (1.1, 3.5, 6.87, ...).

Now, with this PR, it will throw RangeError if n is a factorial number.

Further, I added tests where needed as well as added new test suits for factorial and factoradic.

dankogai commented 6 years ago

Thank you!