Recursive Digit Sum

  • + 0 comments
    Easy JavaScript Solution
    function superDigit(n, k) {
        if(n.length === 1){
            return n
        }
        let p = 0
        for(const num of n){
            const z = k*Number(num)
            p+=z
        }
       return superDigit(p.toString(), 1)
    }