public int addDigits(int num) {
        return num == 0 ? 0 : (num % 9 == 0 ? 9 : num % 9);
    }
Problem: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.
Solution: Read About Digital root in wikipedia.
src/problems/easy/AddDigits.java