1

In python, pow(x,y,z) is equivalent to (x**y)%z, and the former is more efficient than the latter. But why is it useful? In which context does one routinely need to calculate such a quantity (or at least routinely enough for python developers to include it in the language)?

Lachy
  • 218
  • 1
  • 5

1 Answers1

2

This is famously useful for the RSA algorithm. If you try to use x**y%z to encrypt or decrypt a message using RSA, it will be very slow or you could run out of memory, because x**y is large.

Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415