We describe the astrophysical and numerical basis of N -body simulations, both of collisional stellar systems (dense star clusters and galactic centres) and collisionless stellar dynamics (galaxies and large-scale structure). We explain and discuss the state-of-the-art algorithms used for these quite different regimes, attempt to give a fair critique, and point out possible directions of future improvement and development. We briefly touch upon the history of N -body simulations and their most important results.PACS. 98.10.+z Stellar dynamics and kinematics -95.75.Pq Mathematical procedures and computer techniques -02.60.Cb Numerical simulation; solution of equations 1 We shall use the term 'stellar system' for a system idealised to consist of gravitating point masses, whether these are stars, planets, dark-matter particles, or whatever.2 The dynamical or crossing time is a characteristic orbital time scale: the time required for a significant fraction of an orbit. A useful approximation, valid for orbits in inhomogeneous stellar systems, is t dyn ≃ (Gρ) −1/2 withρ the mean density interior to the particles current radius [1]. Note that the complete orbital period is longer by a factor ∼ 3. 3 The minimum impact parameter is well defined for a system containing equal mass point particles: bmin = 2Gm/σ 2 , where σ is the velocity dispersion of the background particles [2]. The maximum impact parameter is related in some way to the extent of the system, but is less well defined. Fortunately, even an order of magnitude uncertainty in bmax has only a small effect since it appears inside a logarithm. Notice that the form of the Coulomb Logarithm has a profound implication: each octave of b contributes equally to ln Λ such that relaxation is driven primarily by weak long-range interactions with b ≫ bmin.