Created
May 27, 2020 16:23
-
-
Save dmurawsky/8e9ea22cea139a61fe797e756bda7533 to your computer and use it in GitHub Desktop.
The pattern of the universe
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 characters
// 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; | |
} |
This pattern is created by multiplying every number by it's previous number and then adding each digit in the number together. So 1+2=2 and 2*3=6 etc. But once you get to multi-digit numbers, you reduce them to a single digit. So 123 * 124 = 15,252 and 1 + 5 + 2 + 5 + 2 = 15 and 1 + 5 = 6.
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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