3 ms·
>> Otherwise, n is definitely composite — no fooling This assertion is false if I understood the test correctly. Take n = 5, a = 2. a ^ ((n - 1) / 2) = 2 ^ (
by rohit89 15y ago
>> Otherwise, n is definitely composite — no fooling
This assertion is false if I understood the test correctly.
Take n = 5, a = 2.
a ^ ((n - 1) / 2) = 2 ^ ((5 - 1) / 2) = 2 ^ 2 = 4
and 4 mod 5 = 4.
Therefore the test will say 5 is composite.
- ColinWright 15y agoNope - (4 mod 5) is -1, so it passes and is not called composite.