Created
November 16, 2021 21:01
-
-
Save Cst2989/23bf5660541f3a46e4d2aea698f5f04f to your computer and use it in GitHub Desktop.
Kaprekar's Constant
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
let number = 7315 | |
const sortedAscending = 1357 | |
const sortedDescening = 7531 | |
const difference = sortedDescening - sortedAscending // subtract the small number from the bigger | |
if (difference === 6174) { | |
console.log('yay') | |
} else { | |
number = difference // we do it again | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment