Numerical Method for the Stability Analysis of Ideal MHD Modes with a Wide Range of Toroidal Mode Numbers in Tokamaks