Formulae to calculate margins for external beam radiotherapy traditionally treat the radiotherapy regimen for analysis purposes as consisting of a very large number of treatment sessions, each delivering a very small dose. It is assumed that the difference in the calculated margin for an infinitely fractionated regimen, and the margin for real world treatment scenarios with finite fractions per patient, is negligible given the usual large number of fractions used to treat most malignancies. However hypofractionated radiotherapy using five fractions or even fewer is becoming increasingly common, causing the accuracy of traditional margin formulae to break down. This work introduces an algorithm that accurately calculates margins for hypofractionated treatment regimens. A method for estimating an upper limit for the required margin is introduced, and an adjustment to the van Herk formula (van Herk et al (2000 Int. J. Radiat. Oncol. Biol. Phys. 47 1121-35)) is used to provide a lower limit. A single-term mathematical model is then used to interpolate between these limits. Results are compared to those calculated by Monte Carlo simulation, demonstrating that the proposed method yields accurate estimates of the actual margin required (consistently within ~1%) for wide ranges of values of the systematic error, random error and penumbral width, even when the number of fractions per patient is as low as 2.