HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /A quick primality test says: if aⁿ⁻¹ not≡ 1 pmod n for some a coprime to n, then n is composite…
AdvancedMathematicsHigh School (11–12)Number TheoryproofNumericalOlympiad

A quick primality test says: if aⁿ⁻¹ not≡ 1 pmod n for some a coprime to n, then n is composite…

StemPy LabContributed by StemPy Lab

Try it on paper first. A hint, the key idea and the worked solution are here when you need them.

A quick primality test says: if an−1≢1(modn)a^{n-1} \not\equiv 1 \pmod nan−1≡1(modn) for some aaa coprime to nnn, then nnn is composite. The number 561561561 fools it. Factor 561561561 into primes. Then prove that a560≡1(mod561)a^{560} \equiv 1 \pmod{561}a560≡1(mod561) for every aaa coprime to 561561561, by applying Fermat's theorem to each prime factor and noting how 560560560 relates to p−1p - 1p−1. Give the smallest and the largest prime factor and the remainder of 25602^{560}2560 on division by 561561561.

Check your answer

Work it out on paper, then type your number. The answer itself stays hidden.

Need a reminder? The key ideaShowHide

For a prime ppp with p∤ap \nmid ap∤a, Fermat's little theorem gives ap−1≡1a^{p-1} \equiv 1ap−1≡1, so exponents can be reduced modulo p−1p - 1p−1:

aq(p−1)+r≡ar(modp).\displaystyle a^{q(p-1) + r} \equiv a^r \pmod p.aq(p−1)+r≡ar(modp).

The worked solution

Check an answer or open a hint to unlock the worked solution.

Have you tried it?

Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.

Given. n=561n = 561n=561 and an integer aaa with gcd⁡(a,561)=1\gcd(a, 561) = 1gcd(a,561)=1.

Step 1. Factor. The digit sum is 121212, so 3∣5613 \mid 5613∣561: 561=3×187=3×11×17561 = 3 \times 187 = 3 \times 11 \times 17561=3×187=3×11×17.

Step 2. The exponent. 560=2×280=10×56=16×35560 = 2 \times 280 = 10 \times 56 = 16 \times 35560=2×280=10×56=16×35. So 560560560 is a multiple of 222, 101010 and 161616, which are p−1p - 1p−1 for p=3,11,17p = 3, 11, 17p=3,11,17.

Step 3. Fermat for each prime. Since aaa is coprime to 561561561, no prime factor divides aaa. So a2≡1(mod3)a^2 \equiv 1 \pmod 3a2≡1(mod3), a10≡1(mod11)a^{10} \equiv 1 \pmod{11}a10≡1(mod11) and a16≡1(mod17)a^{16} \equiv 1 \pmod{17}a16≡1(mod17). Raising to the powers 280280280, 565656 and 353535 gives a560≡1a^{560} \equiv 1a560≡1 modulo each prime.

Step 4. Combine. The three primes are distinct, so their product divides a560−1a^{560} - 1a560−1: a560≡1(mod561)a^{560} \equiv 1 \pmod{561}a560≡1(mod561). Proof complete.

Step 5. The case a=2a = 2a=2. gcd⁡(2,561)=1\gcd(2, 561) = 1gcd(2,561)=1, so 2560≡12^{560} \equiv 12560≡1, remainder 111.

Answer: smallest prime factor 333, largest 171717, and 25602^{560}2560 leaves remainder 111.

What if? A number like this, square-free with p−1∣n−1p - 1 \mid n - 1p−1∣n−1 for every prime factor ppp, is a Carmichael number. This test is called Korselt's criterion.

Log in to save this for later
← All Problems
← Prove that n⁷ - n is a multiple of 42 for every integer n…A music teacher divides a 360-beat cycle into fractions k/360 for k = 1, 2, …, 359… →
More onNumber Theory

Discussion (0)

Log in to join the discussion.

Loading…

More on this topic

  1. The triangular numbers are 1, 3, 6, 10, …, where the nth one is (n(n + 1))/2…Advanced
  2. Prove that the equation x³ + y³ + z³ = n has no solution in integers when n leaves remainder 4 or 5…Advanced
  3. Find every triple of positive integers a ≤ b ≤ c with 1/a + 1/b + 1/c = 1, and prove that there are…Advanced
  4. Find all pairs of positive integers (x, y) with x² - y² = 945…Hard
  5. A teacher wants a list of every primitive Pythagorean triple whose hypotenuse is less than 100…Advanced
All problems on this topic →