Sonar sensor to arduino to servo

but its not working.

That's really, really not helpful.
Describe to us what "working" means to you, and how you code's behaviour differs from that definition.

distance = a;

Did you mean:
a = distance; ?