Home/Study Plan/Number Theory & Divisibility
๐Ÿง 

Brainteasers & Logic

Number Theory & Divisibility

Medium2โ€“3 hrsModular ArithmeticGCDFermatLast DigitRemainders

Overview

Number theory puzzles test recognition of modular patterns. Powers of integers repeat modulo any fixed number โ€” the cycle is always short. Fermat's Little Theorem is the elegant reason: for prime p, a^(p-1) โ‰ก 1. This converts 'what is 2^{1000} mod 101?' into a trivial calculation. The Euclidean GCD algorithm is also directly tested โ€” practice it until it's automatic.

How to Recognize

  • โ†’'What is the last digit of 7^{100}?'
  • โ†’'Find the remainder when dividing X by Y'
  • โ†’GCD/LCM problems
  • โ†’Powers of numbers follow repeating cycles mod any fixed base

Step-by-Step Approach

  1. 1.Last digit = mod 10. Find the cycle: compute a^1, a^2, ... mod 10 until repeat.
  2. 2.Fermat's Little Theorem: a^(pโˆ’1) โ‰ก 1 (mod p) for prime p, gcd(a,p)=1
  3. 3.GCD: Euclidean algorithm โ€” gcd(a,b) = gcd(b, a mod b)
  4. 4.For composite moduli: Euler's theorem: a^ฯ†(n) โ‰ก 1 (mod n)

Key Formulas

01Fermat: apโˆ’1โ‰ก1(modp)a^{p-1} \equiv 1 \pmod{p} (prime pp, gcdโก(a,p)=1\gcd(a,p)=1)
02Euler: aฯ•(n)โ‰ก1(modn)a^{\phi(n)} \equiv 1 \pmod{n} (gcdโก(a,n)=1\gcd(a,n)=1)
03GCD Euclidean: gcdโก(a,b)=gcdโก(b,โ€‰aโ€Šmodโ€Šb)\gcd(a,b) = \gcd(b,\, a \bmod b)
04LCM: lcm(a,b)=ab/gcdโก(a,b)\text{lcm}(a,b) = ab/\gcd(a,b)

Worked Examples

0Quick Example
Last digit of 7^100: cycle is 7โ†’9โ†’3โ†’1 (length 4). 100 mod 4 = 0 โ†’ 4th element = 1. Answer: 1.

Problem

What is the last digit of 3^{47}?

Solution

1

Compute 3^n mod 10: 3^1=3, 3^2=9, 3^3=27โ†’7, 3^4=81โ†’1, 3^5=243โ†’3. Cycle repeats with period 4: (3, 9, 7, 1).

2

47 mod 4 = 3 (since 47 = 11ร—4 + 3).

3

3rd element of cycle (3, 9, 7, 1) = 7.

4

Last digit of 3^{47} = 7.

Answer

7. Cycle for powers of 3 mod 10 has length 4: (3,9,7,1). Since 47โ‰ก3(mod4)47 \equiv 3 \pmod 4, last digit = 7.

Common Mistakes

  • !

    Using Fermat when the modulus is not prime. Fermat requires prime p. For composite n, use Euler's theorem with ฯ†(n).

  • !

    Off-by-one in cycle position when exponent mod period = 0. n mod 4 = 0 means use the FOURTH position of the cycle, not the first.

  • !

    LCM formula: lcm(a,b) = ab/gcd(a,b). Never compute LCM by brute force for large numbers.

Practice Problems

Click "Show Answer" to reveal
1

What is the last digit of 9^{999}?

Hint: Cycle for 9 mod 10: 9, 1, 9, 1, ... (period 2).
2

What is 7^{52} mod 13?

Hint: 13 is prime. Fermat: 7^12 โ‰ก 1 (mod 13). Write 52 = 4ร—12 + 4.
3

What is the sum of all integers from 1 to 100 that are NOT multiples of 3 or 5?

Hint: Total sum minus multiples of 3 minus multiples of 5 plus multiples of 15.

Only works in the Electron app

<webview> is an Electron-only tag. Run npm run electron:dev to use this.

25:00Focus
0

25 min focus ยท 5 min break ยท long break every 4 sessions

The Ultimate Grind