How was this formula of voltage on capacitor achieved?
Let I_r be current in the resistor = Vc/R at any time.


Vc = Q/C from the basic definition of capacitance.
dQ/dt = -I_r = -Vc/R From the basic definition of current.
dQ/dt = -Q/CR


Apply initial conditions, Q at time 0 = Vs * C and do trivial calculus, then substitution to get Vc in place of Q.