def test_modular_exponential(self): self.assertEqual(1, modular_exponential(5, 117, 19)) self.assertEqual( pow(1243, 65321, 10 ** 9 + 7), modular_exponential(1243, 65321, 10 ** 9 + 7) ) self.assertEqual(1, modular_exponential(12, 0, 78)) self.assertRaises(ValueError, modular_exponential, 12, -2, 455)
def test_modular_exponential(self): self.assertEqual(1, modular_exponential(5, 117, 19)) self.assertEqual(pow(1243, 65321, 10**9 + 7), modular_exponential(1243, 65321, 10**9 + 7)) self.assertEqual(1, modular_exponential(12, 0, 78)) self.assertRaises(ValueError, modular_exponential, 12, -2, 455)
from algorithms.maths import modular_exponential ## built in pow print(modular_exponential(24, 2015, 1000))