Update and rename collatz.md to collatz-algorithm.md

This commit is contained in:
Angelos Chalaris
2017-12-14 14:51:44 +02:00
committed by GitHub
parent e44fef2a2a
commit 421f4f46a8
2 changed files with 9 additions and 11 deletions

View File

@ -0,0 +1,9 @@
### Collatz algorithm
If `n` is even, return `n/2`. Otherwise return `3n+1`.
```js
const collatz = n => (n % 2 == 0) ? (n/2) : (3*n+1);
// collatz(8) --> 4
// collatz(5) --> 16
```