(I saw this topic a long time ago, the formula needs to be proven.
I use Google Translate from Vietnamese.)
Prove that the formula $P_{(s)} = (s - 1) \mod 9 + 1$ finds the sum of one digit of an integer greater than 0 with one or more digits.
Prove:
- Let $A$ be the set of integers {$1,2,...,9$}.
- Let $P_{(s)}$ be the sum of one digit of a multi-digit number.
- Based on the formula $P_{(s)} = (s - 1) \mod 9 + 1$, $s > 0$, then $s - 1$ is always $s \ge 0$, so $P_{(s)} € A$.
- Let $a1, a2, a3, ..., an$ be the digits in a number, the value of the set {$0,1,2,...,9$}.
- Let $s$ be a 1 or more digit number.
Me has the general formula of $s$:
\begin{align}
s & = a1*10^0 + a2*10^1 + a3*10^2 + ... + an*10^{n-1}\\
& = a1 + a2*10 + a3*10^2 + ... + an*10^{n-1}\\
& = a1 + a2 + a2*(10^1-1) + a3 + a3*(10^2-1) + ... + an + an*(10^{n-1}-1 )\\
& = a1 + a2 + a3 + ... + an + a2*9 + a3*99 + ... + an*(10^{n-1}-1 )\\
\end{align}
Let b be the value of the expression $a2*9 + a3*99 + ... + an*(10^{n-1}-1)$, based on the sign of divisibility by 9, b is always divisible by 9.
Let $C_{n}$ be the sum of n numbers, the values obtained are respectively:
| $C_{n}$ |
total value |
values |
| $C_{1}$ |
a1 |
$0 \to 1*10-1 = 9*1$ |
| $C_{2}$ |
a1 + a2 |
$0 \to 2*10-2 = 9*2$ |
| $C_{3}$ |
a1 + a2 + a3 |
$0 \to 3*10-3 = 9*3$ |
| $C_{n}$ |
a1 + a2 + a3 + ... + an |
$0 \to n*10-n = 9*n$ |
\begin{align}
Cₙ & = a1 + a2 + a3 + ... + an\\
& = a1 + a2*10 + a3*10^2 + ... + an*10^{n-1} - a2*9 - a3*99 - ... - an*(10^{n-1}-1)\\
& = s - b\\
\end{align}
Conclusion [1] :
- when s loses b value, we get a sum of digits
- [2] When n = 1, then $C_{n}$ € A , $s = C_{n}$, $P_{(s)} = (s - 1) \mod 9 + 1$ is always true.
With s:
\begin{align}
s & = C_{n} + b\\
& = (C_{n})_{C_{n}} + b_{C_{n}} + b\\
& = ((C_{n})_{C_{n}})_{C_{n}} + b_{(C_{n})_{C_{n}}} + b_{C_{n}} + b\\
& = ...((C_{n})_{C_{n}})_{C_{n}} + b...((C_{n})_{C_{n}})_{C_{n}} + ... + b_{(C_{n})_{C_{n}}} + b_{C_{n}} + b\\
\end{align}
Let $Z_{m}$ be the sum of $C_{n}$ the expression of the value s, to get [3] the value $Z_{m} € A$ then:
\begin{align}
s = b + bZ_{0} + bZ_{1} + bZ_{2} + ... + bZ_{m-1} + Z_{m}\\
\end{align}
Let B be the value of the expression $b + bZ_{0} + bZ_{1} + bZ_{2} + ... + bZ_{m-1}$ then:
$$s = Z_{m} + B$$
Based on [1] :
\begin{align}
P_{(s)} & = Z_{m} + B - B\\
& = Z_{m} + B \mod 9\\
\end{align}
Based on [2] and [3] :
\begin{align}
P_{(s)} & = (Z_{m}-1) \mod 9 + 1 + B \mod 9\\
& = (Z_{m} + B - 1) \mod 9 + 1\\
& = (s - 1) \mod 9 + 1\\
\end{align}
Conclusion Thesis:
The formula $P_{(s)} = (s - 1) \mod 9 + 1$ finds the sum of one digit of an integer greater than 0 with one or more digits.