# LeetCode258 Add Digits

## 描述

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.

Could you do it without any loop/recursion in O(1) runtime?

## 思路

$n = a_{n-1} \ast 10^{n-1} + a_{n-2} \ast 10^{n-2} + … a_{1} \ast 10^{1} + a_{0} \ast 10^{0}$

$n \equiv a_{n-1} \ast 1 + a_{n-2} \ast 1 + … a_{1} \ast 1 + a_{0} \ast 1 (mod 9)$