0
How is pow(2,2,3) = 1 in python?
Hii folks...Can anyone please answer me how is pow(2,2,3) result in 1 because generally 2**2**3 is 256.Thanking in advance đ... :)
2 Answers
+ 13
Based on help(pow):
(...)
With three arguments, equivalent to x**y%z, but may be more efficient.
So:
2**2%3 == 4%3 == 1
+ 7
The third argument of pow is modulo. Therefore the result of pow(2,2,3) is (2**2)%3, which is in fact 1. Hope this helps!