public class Solution { public int AddDigits(int num) { var str = num.ToString(); int result = 0; foreach (var c in str) { result += Convert.ToInt32(c.ToString()); } if (result >= 10) { result = AddDigits(result); } return result; } }
https://leetcode.com/problems/add-digits/#/description