This paper describes the method by which it is possible to construct simple algorithms for the calculation of the axial and transverse components of the intensity of the magnetic field of current loops and thin-wall air coils (solenoids). These are planar loops and tightly wound coils with a cross section of an arbitrary shape and parallel walls in an axial direction. Computational algorithms show the same formal structure for every shape of coil; the shape of the coils is defined by the special shape function. The method is based on the superposition of the magnetic field of the equivalent magnetic dipoles. Utilization of this method can be observed, for example, in the calculation of the magnetic field of a cylindrical current loop and a thin cylindrical coil, for which the resulting relations are compared with a familiar method of calculation, on which solving equations for the vector potential is based. The method of calculation described can also be equally effectively used for coils of a noncircular shape. In this study, for the purpose of illustration, simple algorithms are created for the calculation of the magnetic field of a rectangular coil and the calculated values of the magnetic field are compared with the actual measurements.