Skip to content

Instantly share code, notes, and snippets.

@dmurawsky
Created May 27, 2020 16:23
Show Gist options
  • Save dmurawsky/8e9ea22cea139a61fe797e756bda7533 to your computer and use it in GitHub Desktop.
Save dmurawsky/8e9ea22cea139a61fe797e756bda7533 to your computer and use it in GitHub Desktop.
The pattern of the universe
// Usage: Run the below code in your termainal by either running node and copying the code into the REPL or by saving the code to a file and running node pattern.js
// It will output a consistent pattern no matter how high you count.
// Change 1000 to a higher number to test it
let number = 1;
while (number < 1000) {
next = number + 1;
let reduce = number * next + "";
while (reduce.length > 1) {
reduce = reduce.split('').reduce((prev, num) => prev + parseInt(num), 0) + "";
}
console.log(reduce);
number = next;
}
@dmurawsky
Copy link
Author

dmurawsky commented Jul 12, 2020

If you add instead of multiply you get a different pattern: 3,5,7,9,2,4,6,8,1

3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6,8,1,3,5,7,9,2,4,6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