Snippets Collections
class Solution
{
    public static int digitalRoot(int n)
    {
        if(n < 10)
            return n;

        return digitalRoot(n%10 + n/10);
    }
}
star

Sun Feb 06 2022 22:48:51 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/digital-root/1/?track=DSASP-Recursion&batchId=190

#java #gfg #geeksforgeeks #recursion #digitalroot

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension