The computational code for designing the resonant cavity of a gyrotron has been developed to design new gyrotrons for the future GAMMA 10(PDX). The developed code calculates the cavity RF profile function by simultaneously solving a set of relativistic single-particle equations of motion and wave equations to obtain a self-consistent solution in the dynamic system that accounts for the effects of the electron beam on the cavity field profile. Beam-wave interactions mainly occur in the uniform middle section of the resonator. The calculation results explain well experimental data of the gyrotron used in GAMMA 10 ECH system.