the problem is in your recursion, when it backs out sum is the old value, you need to change your recursive call to:


if(sum>9) {
sum = Add(sum);
}