It is not amazing. It is basic math.
Divide your telephone to x (1st 3 digit) and y (last 4 digits)
1st Step : 80 * x
2nd step add 1 = (80x +1)
3rd step multiply by 250 = 80x*250 +250 = 20000x +250
4th step = add 4 digits twice = y+y =2y. The equation is now 20000x+250+2y
5th step = subtract 250. The equation is now 20000x+250+2y-250= 20000x+2y
6th Step = Divide by 2. The equation is 10000x+y
This will leave the x beyond the 1000 place and y as it is.