It's just a bloody simple system of differential equations. n bodies, each has a location (3 coordinates) and a speed vector (3 coordinates), so you have six equations. The speed is obviously the derivative of the location, and the theory gives you the equation to calculate the derivative of the speed. Look up Fehlberg or "Adaptive Runge-Kutta-Fehlberg" and you are there.
With relativity things get hard, quick. Both time (thus, speed) and space (thus, speed and distance) dilate, mass changes (thus, the attractive forces between bodies and thus their acceleration, and thus their speed, and thus their location), and some other oddities.