Skip to content

Instantly share code, notes, and snippets.

@Cst2989
Created November 16, 2021 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cst2989/23bf5660541f3a46e4d2aea698f5f04f to your computer and use it in GitHub Desktop.
Save Cst2989/23bf5660541f3a46e4d2aea698f5f04f to your computer and use it in GitHub Desktop.
Kaprekar's Constant
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