Your code gives wrong output for such type of test cases, which is common on larger numbers-
1007 2009767 55
On changing 1007 to 1045 (which is the 19th multiple of 55) your code prints correct output since you made sure to include those type of cases.
The difference between your logics is that in computer, you cannot claim that b/m -a/m = (b-a)/m always.
Take example of- b=10, a=8,m=9
Check this test case also-
11 100 9
What you are doing is, (100-11)/9=89/9=9 Neither 100 nor 11 are multiple of 9.
What he did is, 100/9 - (11-1)/9=11-1=10.
To correct it, you should adjust a and b to nearest allowed multiple of the number. Like, a should be raised to nearest multiple of m, and b should be lowered to nearest multiple of n. Then your code prints correct answer.
In the end, by (b-a)/m we are seeing how many multiples of m we can fit inside the range STARTING from a.
If you start from 11, you can fit multiples in range of 11 to (11+81) = [11,92]. The multiples in this range is 9.
But we can prove by contradiction, that if you start from 18, multiples will be more. [11+7,92+7]=[18,99]. There is 1 more multiple here. This is the edge case to your logic.