Last active
December 21, 2019 21:35
-
-
Save emukupa/08d88c4d26b5d934e4f9cd7ab8def66d to your computer and use it in GitHub Desktop.
Revisions
-
emukupa revised this gist
Dec 21, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ function mersenneSequence(upTo = 10) { return list; } console.log(mersenneSequence()); // you can pass in a number, if not 10 is used /* [ 0, 1, 3, 7, -
emukupa created this gist
Dec 21, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ const mersenneSequenceNumber = x => 2 * x + 1; // f(x) = 2x + 1 function mersenneSequence(upTo = 10) { const list = [0]; // init with the first number // make the rest using the previous number in the list for (let i = 0; i < upTo; i++) { list.push(mersenneSequenceNumber(list[i])); } return list; } console.log(mersenneSequence()); /* [ 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023 ] */