class Solution {
public:
int addDigits(int num) {
while(num>=10)
{
int ans = 0;
while(num)
{
ans+=num%10;
num/=10;
}
num = ans;
}
return num;
}
};