

            pwrmod (4) --- calculate an exponential modulo a given modulus  07/20/84


          | _C_a_l_l_i_n_g _I_n_f_o_r_m_a_t_i_o_n

                 long_int function pwrmod (p, e, n)
                 long_int p, e, n

          |      Library: vswtmath (Subsystem mathematical library)


            _F_u_n_c_t_i_o_n

                 'Pwrmod' is used to perform an integer exponentiation in the
                 ring  of  integers modulo a given modulus.  The argument 'p'
                 is the base of the expression, 'e' is the exponent, and  'n'
                 the modulus.  The function return is p**E (mod n).


            _I_m_p_l_e_m_e_n_t_a_t_i_o_n

                 'Pwrmod'  examines  the  exponent a bit a time, squaring the
                 intermediate result accumulated so far and multiplying it by
                 the base whenever the selected bit is a 1.   Each  operation
                 is  performed modulo 'n', so that intermediate results don't
                 become excessively large.


            _S_e_e _A_l_s_o

                 invmod (4)






























            pwrmod (4)                    - 1 -                    pwrmod (4)


