DEV Community

Discussion on: Solving the Digital Root Algorithm using JavaScript

Collapse
 
ph1p profile image
Phil

Thank you! I like those tiny little programming "snacks" :)


shortest (recursion) solution I could find:

const dr = r => r < 10 ? r : dr([...r+''].reduce((b,c) => +b+(+c)));

dr(129); // 3