Maths WorkshopMaths problems with full solutions
Exercise 555Number theory › PrimesHigh schoolAdded 3 Nov 2026

Trial division primality test

#trial division#primality test#algorithm

Statement

Test whether 127127 is prime using trial division.

Hint

Test divisibility by primes up to 127≈11.3\sqrt{127}\approx11.3.

Show solutionHide solution

Solution

Primes to test. 2,3,5,7,112,3,5,7,11.

Divisibility.
- 22: 127127 odd, no.
- 33: 1+2+7=101+2+7=10, not divisible by 33.
- 55: ends in 77, no.
- 77: 127=7⋅18+1127=7\cdot18+1, no.
- 1111: alternating sum 7−2+1=67-2+1=6, not 00, no.

Conclusion. 127127 is prime.