1 line solution using Recursion


  • 0
    A
    public class Solution {
        public int addDigits(int num) {
            return (num<10)? num: addDigits(num%10+addDigits(num/10));
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.