Last active
December 30, 2019 22:00
-
-
Save secretgspot/46acb7802761e30aa0380445de4e2ce6 to your computer and use it in GitHub Desktop.
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
// https://www.youtube.com/watch?v=Wim9WJeDTHQ | |
let steps = 0; | |
const per = (num) => { | |
steps++; | |
let digits = [...String(num)].map(i => Number(i)); | |
let result = digits.reduce((acc, cur) => acc * cur); | |
if (result == 0 | |
|| String(result).length == 1 | |
|| Number.isNaN(result)) { | |
console.log(result); | |
console.log('Steps:', steps); | |
return; | |
}; | |
console.log(result); | |
per(result); | |
} | |
per(277777788888899); // 11 steps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment