class Solution {

public:

int addDigits(int num) {

if( num < 10) return num;

```
while(num > 9)
{
int sum = 0;
while(num>9)
{
sum = sum + num%10;
num = floor(num/10);
}
num = sum+ num;
}
return num;
}
```

};