changed
I changed 'javascript' in 'js'
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
If n even then returns **n/2** otherwise (n is odd) **3n+1**.
|
If n even then returns **n/2** otherwise (n is odd) **3n+1**.
|
||||||
It uses the ternary operator.
|
It uses the ternary operator.
|
||||||
|
|
||||||
``` javascript
|
``` js
|
||||||
const collatz = n => (n % 2 == 0) ? (n/2) : (3*n+1);
|
const collatz = n => (n % 2 == 0) ? (n/2) : (3*n+1);
|
||||||
// collatz(8) --> 4
|
// collatz(8) --> 4
|
||||||
// collatz(5) --> 16
|
// collatz(5) --> 16
|
||||||
|
|||||||
Reference in New Issue
Block a user