mystery3 method

public static int sumEvenDigits(int n)
{
    if(n == 0)
        return 0;
    
    if(n % 2 == 0)
        return n % 10 + sumEvenDigits(n / 10);
    else
        return sumEvenDigits(n / 10);
}

The method returns the sum of the even digits of its parameter n.

The analysis is nearly identical to mystery1/countOddDigits. The only difference is that on 1 step, the method adds n % 10 (the last digit of n) to the result, instead of adding 1.

mystery2 solution
mystery4 solution
Exercises
All solutions