public class Solution {
public int AddDigits(int num) {
var str = num.ToString(); int result = ; foreach (var c in str)
{
result += Convert.ToInt32(c.ToString());
} if (result >= )
{
result = AddDigits(result);
} return result;
}
}
public class Solution {
public int AddDigits(int num) {
var str = num.ToString(); int result = ; foreach (var c in str)
{
result += Convert.ToInt32(c.ToString());
} if (result >= )
{
result = AddDigits(result);
} return result;
}
}