javascript
javascript copied to clipboard
Update collatz.js
Strict mode, better docs, refactoring, support for negatives, protection against infinite loops, etc...
I am creating a pull request for...
- [ ] New algorithm
- [x] Update to an algorithm
- [x] Fix an error
- [x] Other -...
"Collatz conjecture" is not a sequence. The standard-de-facto name convention is "Hailstone sequence", that's why I edited the comments.
I added JSdoc to explicitly specify the expected type of n, to reduce the likelihood of misuse of that function
I haven't tested it yet, that's why it's a draft. Please be patient, I'll test later