Let's say I have multiplication table 20 a = 20
A point on grid let say say 517 b = 517
Now I need a formula to find nearest number on both sides of this point on multiplication table. The answer will be 500 and 520. What could be the formula to get these both numbers using a and b
Or in other words closest multiples of 20 on either side of 517?
In your example, the reason we get the answer to be $500$ and $520$ is because $$\lfloor517\div20\rfloor=25\quad\text{and}\quad20\times25=500\quad\text{and}\quad20\times26=520.$$
As such, in general, we have the two answers as needed as $$a\left\lfloor\frac{b}{a}\right\rfloor\quad\text{and}\quad a\left(\left\lfloor\frac{b}{a}\right\rfloor+1\right).$$