https://leetcode.com/problems/add-digits/
class Solution { public: int addDigits(int num) { int res=num; while(oneDigit(res)==false) { int temp=0; while(res!=0) { temp+=res%10; res/=10; } res=temp; } return res; } bool oneDigit(int num) { if(num<=9) return true; else return false; } };