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 😊... :)

17th Jun 2017, 6:16 PM
S.Naveen Kumar
S.Naveen Kumar - avatar
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
17th Jun 2017, 6:33 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 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!
17th Jun 2017, 6:33 PM
Jared
Jared - avatar