The formula for calculating the perimeter of a rectangle is p=2l+2w, where p represents the perimeter, l represents the length, and w represents the width. This formula can be used to find the perimeter when the length and width are known.