Created
November 12, 2018 19:16
-
-
Save runandrerun/f43d5eaa630c2b4e5271e59518c12dcb to your computer and use it in GitHub Desktop.
Questions
This file contains 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
// JavaScript | |
strangeSequence = (num) => { | |
let numbers = [] | |
let count = 1 | |
while (numbers.indexOf(num) === -1) { | |
count++ | |
numbers.push(num) | |
num = ("" + num).split("").map(num => num * num).reduce((a, b) => a + b) | |
} | |
return count | |
} | |
strangeSequence(16) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment