Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
20
Task/Hailstone-sequence/JavaScript/hailstone-sequence-2.js
Normal file
20
Task/Hailstone-sequence/JavaScript/hailstone-sequence-2.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
(function () {
|
||||
|
||||
// Hailstone Sequence
|
||||
// n -> [n]
|
||||
function hailstone(n) {
|
||||
return n === 1 ? [1] : (
|
||||
[n].concat(
|
||||
hailstone(n % 2 ? n * 3 + 1 : n / 2)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
var lstCollatz27 = hailstone(27);
|
||||
|
||||
return {
|
||||
length: lstCollatz27.length,
|
||||
sequence: lstCollatz27
|
||||
};
|
||||
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue