Skip to content

Instantly share code, notes, and snippets.

@Luisgustavom1
Created May 25, 2024 19:54
Show Gist options
  • Save Luisgustavom1/3f26a639e5f0c4a8260c52107e4a0453 to your computer and use it in GitHub Desktop.
Save Luisgustavom1/3f26a639e5f0c4a8260c52107e4a0453 to your computer and use it in GitHub Desktop.
function digitalRoot(n) {
if (n < 10) {
return n;
}
let nu = n
let s = 0
while(nu > 0) {
const r = nu % 10
s += r
nu = (nu - r) / 10
}
return digitalRoot(s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment