ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
print(pow(2, 10**18, 10**9 + 7) == pow(2, 10**18 % (10**9 + 6), 10**9 + 7))
- A. True
- B. False
- C. ValueError
- D. 1
Correct answer: A. True
Fermat's little theorem says exponents of 2 can be reduced modulo p - 1 when p = 10**9 + 7 is prime and 2 is not a multiple of p. So both sides give the same residue.
More Python Programming questions
- What is printed? python print(7 // 0.5, 7 % 0.5, 0.5 7 // 1, 1e308 10 == float('inf'))
- What is printed? python print(sum([True, True, False]), True 3, 'ab' True, [0] True)
- What is printed? python print('%x' % 255, '%X' % 255, '%#o' % 8, '%+d' % 0)
- What is printed? python print(float('1e-7'), 0.000001, 1e-6 == 0.000001, 123456789012345678.0)
- What is printed? python print(round(0.5 + 1), round(-0.5 - 1), round(2.5 - 0.0001))
- What is printed? python print(0.1 + 0.2 - 0.3, 0.3 - 0.1 - 0.2, 1 / 49 49, 1 / 10 10)