> For the complete documentation index, see [llms.txt](https://liuyang89116.gitbook.io/my-leetcode-book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://liuyang89116.gitbook.io/my-leetcode-book/post_chapter_2_math/problem_67_add_binary/problem-258-add-digits.md).

# Problem 258: Add Digits

> <https://leetcode.com/problems/add-digits/#/description>

## 思路

* 这其实算数学题，有现成的公式可以用。

> <https://en.wikipedia.org/wiki/Digital_root#Congruence_formula>

```java
public class Solution {
    public int addDigits(int num) {
        return 1 + (num - 1) % 9;
    }
}
```
