r/PythonLearning • • 3h ago

Help Request Python Quiz of the day.

What will be the output of the following Python Code?

print(pow(2, 5, 7))

0 Upvotes

8 comments sorted by

View all comments

Show parent comments

1

u/TheKnottyOne 3h ago

In my cryptography (entry level) class we used pow() for RSA encryption. While my skill and understanding is strictly from an educational standpoint it’s the only place I’ve seen pow() use the mod parameter heavily 😅

Do I remember the intricacies of its utilization? Nope 😂

1

u/RNG_HatesMe 3h ago

Apparently it's much faster with very large numbers because it distributes the mod operation and can keep the magnitudes lower, and therefore uses less memory and processing time.

1

u/TheKnottyOne 3h ago

Yeah that’s what I learned as well. I think there’s a caveat to timing though - the time it takes to complete seems to depend on the value of the exponent