#C10576. Digital Root of a Product
Digital Root of a Product
Digital Root of a Product
Given two non-negative integers x and y, compute the digital root of their product.
The digital root of a number \(n\) is given by:
$$ \text{dr}(n) = \begin{cases} 0, & \text{if } n = 0, \\ 1 + ((n - 1) \bmod 9), & \text{if } n > 0. \end{cases} $$
Your task is to read the two integers from stdin, compute \(x \times y\), then output its digital root to stdout.
inputFormat
The input consists of two non-negative integers x and y separated by space.
Example:
5 7
outputFormat
Output a single integer which is the digital root of the product of x and y.
Example:
8## sample
5 7
8
</p>