mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
14 lines
156 B
Go
14 lines
156 B
Go
package leetcode
|
|
|
|
func addDigits(num int) int {
|
|
for num > 9 {
|
|
cur := 0
|
|
for num != 0 {
|
|
cur += num % 10
|
|
num /= 10
|
|
}
|
|
num = cur
|
|
}
|
|
return num
|
|
}
|