Maths WorkshopMaths problems with full solutions
Exercise 1130Number theory › PrimesL1Added 3 Nov 2026

Fermat primality test

#Fermat test#primality#witness

Statement

Test whether 3535 is prime using the Fermat test with base 22.

Hint

Compute 234(mod35)2^{34}\pmod{35}. If ≠1\neq1, 3535 is composite.

Show solutionHide solution

Solution

Compute. 24=162^4=16, 25=32≡−3(mod35)2^5=32\equiv-3\pmod{35}, 210≡92^{10}\equiv9, 220≡81≡112^{20}\equiv81\equiv11, 230≡11⋅9=99≡29(mod35)2^{30}\equiv11\cdot9=99\equiv29\pmod{35}, 234=230⋅24≡29⋅16=464≡464−13⋅35=464−455=9(mod35)2^{34}=2^{30}\cdot2^4\equiv29\cdot16=464\equiv464-13\cdot35=464-455=9\pmod{35}.

Result. 234≡9≠1(mod35)2^{34}\equiv9\neq1\pmod{35}.

Conclusion. 3535 is composite (as expected: 35=5⋅735=5\cdot7).