Modular exponentiation: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: removed three tests that needn't be performed, used a template for the output.. |
|||
Line 292: | Line 292: | ||
# Compute self**e mod m |
# Compute self**e mod m |
||
def powmod(e, m) |
def powmod(e, m) |
||
r = 1.to_big_i |
r, b = 1, self.to_big_i % m |
||
b = self.to_big_i % m |
|||
while e > 0 |
while e > 0 |
||
r = (r * b) % m if e.odd? |
r = (r * b) % m if e.odd? |