How many positive integers x≤10000 are there such that the difference 2x−x2 is not divisible by 7?
7142
2x−x2 is divisible by 7 if and only if 2x and x2 both leave the same remainder when divided by 7.
x2xRemainder with 7 1222443814162532466417128282564
xx2Remainder with 7 111244392416252546361749086419814101002
Remainder of 2x repeats after every 3 and remainder of x2 repeats after 7. The remainders of both 2x and x2 will repeat after a period of length 3×7 = 21
x1234567891011121314151617181920212x241241241241241241241x2142241014224101422410
In this set of 21 values, we see that there are 6 values of x for which the remainders are same.
As per the periodicity, within every consecutive 21 values, 6 will repeat.
10,000 = 21×476 + 4
The 476 groups contribute 476×6 = 2856 values and the remaining 4 will give 2 values.
So, total 2858 integers ≤10000 are divisible. Thus, 10000- 2858 = 7142 integers are not divisible.