Solution (source code)

= Solution

Divisibility by $2$ or $5$ depends only on the final digit. As the digits are cyclically rotated, every digit appears in the final position. Thus every rotation is divisible by $d\in\{2,5\}$ exactly when every digit is divisible by $d$.