#P10985. Zero Transformation via Digit Sum Subtraction
Zero Transformation via Digit Sum Subtraction
Zero Transformation via Digit Sum Subtraction
You are given a positive integer \( n \). Every minute, the number transforms as follows:
\[ n \leftarrow n - S(n) \]
where \( S(n) \) denotes the sum of the digits of \( n \). The process repeats until \( n \) becomes \( 0 \). Your task is to determine after how many minutes \( n \) becomes \( 0 \).
For example, if \( n = 23 \):
- After 1 minute: \( 23 - (2+3) = 18 \)
- After 2 minutes: \( 18 - (1+8) = 9 \)
- After 3 minutes: \( 9 - 9 = 0 \)
So, the answer is 3.
inputFormat
The input consists of a single positive integer \( n \) (\(1 \leq n \leq 10^9\)).
outputFormat
Output a single integer representing the number of minutes it takes for \( n \) to become \( 0 \).
sample
23
3
</p>