Coprime to N in a Range
Count the integers in [L, R] that are coprime with N.
Input: one line with three integers L, R, N.
Output: the count of coprime integers.
Constraints:
- 1 ≤ L ≤ R ≤ 1012
- 1 ≤ N ≤ 109
Sample Tests
Input 1
1 10 6
Output 1
3
Input 2
1 1 5
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.