Given an integer num, repeatedly add all its digits until the result has only one digit, and return it.
func addDigits(num int) int {
for ;num >= 10 ; {
temp := 0
for ; num != 0 ; {
temp += num % 10
num = (num - num % 10) / 10
}
num = temp
}
return num
}