DEV Community

Discussion on: Solving the Digital Root Algorithm using JavaScript

Collapse
 
sabyrcpu profile image
sabyr-cpu

The better solution I think:

function digital_root(n) {
return (n - 1) % 9 + 1;
}