#K82637. Check Divisibility by 3 via Consecutive Digits Product Sum
Check Divisibility by 3 via Consecutive Digits Product Sum
Check Divisibility by 3 via Consecutive Digits Product Sum
You are given an integer M. Your task is to check whether the sum of the products of each pair of consecutive digits in M is divisible by 3.
If the number consists of less than two digits, it is considered to automatically satisfy this condition.
Let the digits of M be \(d_1,d_2,\dots,d_k\). Then compute the sum
\[
S = \sum_{i=1}^{k-1} d_i \times d_{i+1}
\]
and check whether \(S \mod 3 = 0\). If yes, output True
; otherwise, output False
.
inputFormat
The input consists of a single line containing an integer M.
outputFormat
Output a single line containing either True
if the computed sum is divisible by 3, or False
otherwise.
5
True