Skip to content
Number Theory · Chapter 24

Modular Arithmetic

Work with remainders instead of huge numbers: wrap around a clock, spot digit cycles, and use Euler, Fermat, Wilson and the Chinese Remainder Theorem to tame enormous powers.

24.0a0%

Congruences and Cycles

In this section you will be able to replace big numbers by their remainders, use negative remainders, and find the cycle of a power.

open on YouTube

Multiply 9×99×999×⋯9 \times 99 \times 999 \times \cdots all the way to a number with 999 nines. The last three digits? Every factor after the second is −1-1 mod 10001000.

Modular arithmetic only keeps the remainder. Think of a clock with mm spots: 1717 on a 6-hour clock is the same spot as 55.

Look: you can swap any number for its remainder before you add, multiply or take powers. The answer lands on the same spot. A negative name often helps: 999≡−1(mod1000)999 \equiv -1 \pmod{1000}.

Exploreplay first, formulas later

99 × 999 = 98901 ≡ 901 (mod 1000); 99 × (-1) = -99 ≡ 901 (mod 1000)

mod m1000
a99
b999
901 = -990 (mod 1000)
The big numbers
99 × 999 = 98,901 ≡ 901 (mod 1000)
Swap in the remainders first
99 × (-1) = -99 ≡ 901 (mod 1000)

Same spot on the dial! You never needed the big numbers.

99 × 999 = 98901 ≡ 901 (mod 1000)

99 × 999 = 98901 ≡ 901 (mod 1000); 99 × (-1) = -99 ≡ 901 (mod 1000)

Name it

Definition 24.0.1 · Congruence

n≡a(modb)n \equiv a \pmod{b}

means that the number nn leaves the same remainder as aa when divided by bb. Equivalently, bb divides n−an - a. Read it as “nn is congruent to aa mod bb”.

Theorem 24.0.2 · Multiplying Congruences

If a≡x(modn)a \equiv x \pmod{n} and b≡y(modn)b \equiv y \pmod{n}, then

ab≡xy(modn).ab \equiv xy \pmod{n}.

(The book prints the first congruence as “a=x(modn)a = x \pmod n”; it means ≡\equiv.)

Theorem 24.0.3 · Powers of Congruences

If a≡x(modn)a \equiv x \pmod{n}, then

am≡xm(modn)a^m \equiv x^m \pmod{n}

for every positive integer mm.

Concept 24.0.4 · Digit Cycles

To find the last digit(s) of a huge power aba^b, compute the first few values of aba^b and look for a pattern. The remainders must eventually repeat, so the pattern carries over to large bb.

2^k mod 10 repeats 2, 4, 8, 6 (length 4)

base2
mod10
0123456789
  1. 212^{1}2
  2. 222^{2}4
  3. 232^{3}8
  4. 242^{4}6
cycle length 4

2^k mod 10 repeats 2, 4, 8, 6 (length 4)

Watch itpredict, then reveal

Example 24.1

AIME

Find the remainder when 9×99×999×⋯×99⋯9⏟999 9’s9 \times 99 \times 999 \times \cdots \times \underbrace{99\cdots9}_{\text{999 9's}} is divided by 10001000.

Clock dial (its total is revealed at the end of the example)

mod m1000
a999
b9999
10 (mod 1000)
The big numbers
999 × 9,999 = 9,989,001 ≡ 1 (mod 1000)
Swap in the remainders first
(-1) × (-1) = 1 ≡ 1 (mod 1000)

Same spot on the dial! You never needed the big numbers.

999 × 9999 = 9989001 ≡ 1 (mod 1000)

999 × 9999 = 9989001 ≡ 1 (mod 1000); (-1) × (-1) = 1 ≡ 1 (mod 1000)

  1. 1

    By Theorem 24.0.2 you may replace every factor by its remainder mod 10001000. What is 999999 mod 10001000, written as a negative number?

    Predict first:
open on YouTube

Example 24.2

AMC 12

Let SS be a subset of {1,2,3,…,30}\{1, 2, 3, \dots, 30\} with the property that no pair of distinct elements in SS has a sum divisible by 55. What is the largest possible size of SS?

Clock dial (its total is revealed at the end of the example)

mod m5
1 to N30
0×61×62×63×64×6
How many of 1 to N land on each spot
0: 61: 62: 63: 64: 6

Spots joined by a chord add up to a multiple of 5: take only one side of each chord.

Largest set with no pair summing to a multiple of m
? (hidden until the end of the example)
?

Residue classes (mod 5)

  1. 1

    Whether a sum is divisible by 55 depends only on the remainders. Sort 1,…,301, \dots, 30 by remainder mod 55. How many numbers land in each class?

    Predict first:
open on YouTube

Example 24.3

AMC 12

Let k=20082+22008k = 2008^2 + 2^{2008}. What is the units digit of k2+2kk^2 + 2^k?

Power cycle (its total is revealed at the end of the example)

base2
mod10
0123456789
  1. 212^{1}2
  2. 222^{2}4
  3. 232^{3}8
  4. 242^{4}6
  5. 252^{5}2
  6. 262^{6}4
  7. 272^{7}8
  8. 282^{8}6

The units digits repeat every 4 powers: 2, 4, 8, 6.

cycle length 4

2^k mod 10 repeats 2, 4, 8, 6 (length 4)

  1. 1

    What is the units digit of 200822008^2?

    Predict first:
open on YouTube

Try it

Problem 24.1.1

Omega Learn

Find the remainder when 36936^9 is divided by 55.

Problem 24.1.2

Omega Learn

Find the remainder when 34934^9 is divided by 55.

Contest cornerreal contest problems

Problem 24.1.18(additional)

AMC 10

What is the remainder when 30+31+32+⋯+320093^0 + 3^1 + 3^2 + \cdots + 3^{2009} is divided by 88?

Problem 24.1.12

AMC 10

How many of the first 20182018 numbers in the sequence 101,1001,10001,100001,…101, 1001, 10001, 100001, \dots are divisible by 101101?

Problem 24.1.21(additional)

AMC 10

How many distinct four-digit numbers are divisible by 33 and have 2323 as their last two digits?

Checkpoint for section 24.0a

Get 2 of 3 right to master this section. One try each, no hints.
1

What is the remainder when 21002^{100} is divided by 77?

2

What is the units digit of 720257^{2025}?

3

Find the remainder when 1234×56781234 \times 5678 is divided by 99.

24.0b0%

Euler, Fermat, Wilson and the Binomial Theorem

In this section you will be able to count with Euler's φ, shrink huge exponents with Euler and Fermat, find inverses, and use Wilson and the binomial theorem.

open on YouTube

What is 683+8836^{83} + 8^{83} mod 4949? Powers of 66 mod 4949 repeat, and the cycle length divides φ(49)=42\varphi(49) = 42. So 6836^{83} is really 6−16^{-1}.

φ(n)\varphi(n) counts the numbers from 11 to nn that share no factor with nn. Strike out the multiples of each prime factor and count what is left.

Look: when gcd⁡(a,n)=1\gcd(a, n) = 1, aφ(n)≡1(modn)a^{\varphi(n)} \equiv 1 \pmod n. So you can cut any exponent down mod φ(n)\varphi(n). For a prime pp this is Fermat: ap−1≡1a^{p-1} \equiv 1.

Exploreplay first, formulas later

n = 36 = 2^2 · 3^2; nothing struck: 36 left; 36 = 36

n36
= 2² · 3²
Survivors: 3636 = 36

Nothing struck yet: all n numbers are here.

n = 36 = 2^2 · 3^2; nothing struck: 36 left; 36 = 36

Name it

Theorem 24.0.5 · Euler's Totient Function

If nn has the prime factorization p1e1p2e2⋯pkekp_1^{e_1} p_2^{e_2} \cdots p_k^{e_k}, then

φ(n)=n(1−1p1)(1−1p2)⋯(1−1pk),\varphi(n) = n\left(1 - \frac{1}{p_1}\right)\left(1 - \frac{1}{p_2}\right)\cdots\left(1 - \frac{1}{p_k}\right),

where φ(n)\varphi(n) is the number of positive integers ≤n\le n that are relatively prime to nn.

Steps: 1. Find the prime factorization of nn. 2. For each prime pip_i, form 1−1pi1 - \frac{1}{p_i} and multiply them. 3. Multiply that product by nn.

Theorem 24.0.6 · Euler's Totient Theorem

For n>1n > 1,

aφ(n)≡1(modn)a^{\varphi(n)} \equiv 1 \pmod{n}

if and only if gcd⁡(a,n)=1\gcd(a, n) = 1.

6^k mod 49 repeats 6, 36, 20, 22, 34, 8, 48, 43, 13, 29, 27, 15, … (length 14); φ(49) = 42, and the cycle length 14 divides 42

base6
mod49
  1. 616^{1}6
  2. 626^{2}36
  3. 636^{3}20
  4. 646^{4}22
  5. 656^{5}34
  6. 666^{6}8
  7. 676^{7}48
  8. 686^{8}43
  9. 696^{9}13
  10. 6106^{10}29
  11. 6116^{11}27
  12. 6126^{12}15
  13. 6136^{13}41
  14. 6146^{14}1

The remainders mod 49 repeat every 14 powers: 6, 36, 20, 22, 34, 8, 48, 43, 13, 29, 27, 15, ….

φ(49) = 42, and the cycle length 14 divides 42

cycle length 14

6^k mod 49 repeats 6, 36, 20, 22, 34, 8, 48, 43, 13, 29, 27, 15, … (length 14); φ(49) = 42, and the cycle length 14 divides 42

Corollary 24.0.7 · Fermat's Little Theorem

If pp is a prime and p∤ap \nmid a, then

ap−1≡1(modp).a^{p-1} \equiv 1 \pmod{p}.

(The book says “if and only if pp is a prime and gcd⁡(a,n)=1\gcd(a, n) = 1”. The converse is false: 561=3⋅11⋅17561 = 3 \cdot 11 \cdot 17 is not prime, yet a560≡1(mod561)a^{560} \equiv 1 \pmod{561} for every aa coprime to 561561.)

Sixth powers mod 7 can only leave {0, 1}

power k6
mod m7

Sixth powers mod 7 can only leave

  • 0 ✓
  • 1 ✓
  • 2
  • 3
  • 4
  • 5
  • 6

5 residues never show up.

{0, 1}

Sixth powers mod 7 leave {0, 1}

Concept 24.0.8 · Modular Inverses

If ab≡1(modn)ab \equiv 1 \pmod{n}, then aa is the modular inverse of bb (mod nn), and bb is the inverse of aa. We write

a−1≡b(modn).a^{-1} \equiv b \pmod{n}.

An inverse of aa exists exactly when gcd⁡(a,n)=1\gcd(a, n) = 1.

3⁻¹ ≡ 5 (mod 7); 3 × 5 = 15 ≡ 1 (mod 7)

mod m7
a3
0123456
Hop by a until you land on 1
3 × 5 = 15 ≡ 1 (mod 7)
3−13^{-1} ≡ 5 (mod 7)
3⁻¹ ≡ 5 (mod 7)

3⁻¹ ≡ 5 (mod 7); 3 × 5 = 15 ≡ 1 (mod 7)

Theorem 24.0.9 · Wilson's Theorem

For a prime pp,

(p−1)!≡p−1≡−1(modp).(p-1)! \equiv p - 1 \equiv -1 \pmod{p}.

6! = 720 ≡ 6 ≡ -1 (mod 7)

mod m7
a6
01-62-53-44-35-26-1
Running product 1 × 2 × 3 × …
6! = 720 ≡ 6 ≡ -1 (mod 7)
6! = 720 ≡ 6 ≡ -1 (mod 7)

6! = 720 ≡ 6 ≡ -1 (mod 7)

Theorem 24.0.10 · Binomial Theorem

For non-negative nn,

(x+y)n=(n0)xny0+(n1)xn−1y+(n2)xn−2y2+⋯+(nn)x0yn.(x+y)^n = \binom{n}{0}x^n y^0 + \binom{n}{1}x^{n-1}y + \binom{n}{2}x^{n-2}y^2 + \cdots + \binom{n}{n}x^0 y^n.

In modular arithmetic, write a big base as “small number + multiple of 10”: in (1+10)n(1 + 10)^{n} every term from 10310^3 on vanishes mod 10001000, so (1+10)n≡1+10n+100(n2)(mod1000)(1 + 10)^n \equiv 1 + 10n + 100\binom{n}{2} \pmod{1000}.

Watch itpredict, then reveal

Example 24.4

AIME

Let an=6n+8na_n = 6^n + 8^n. Determine the remainder upon dividing a83a_{83} by 4949.

Power cycle (its total is revealed at the end of the example)

base6
mod49
  1. 616^{1}6
  2. 626^{2}36
  3. 636^{3}20
  4. 646^{4}22
  5. 656^{5}34
  6. 666^{6}8
  7. 676^{7}48
  8. 686^{8}43
  9. 696^{9}13
  10. 6106^{10}29
  11. 6116^{11}27
  12. 6126^{12}15
  13. 6136^{13}41
  14. 6146^{14}1

The remainders mod 49 repeat every 14 powers: 6, 36, 20, 22, 34, 8, 48, 43, 13, 29, 27, 15, ….

φ(49) = 42, and the cycle length 14 divides 42

cycle length 14

6^k mod 49 repeats 6, 36, 20, 22, 34, 8, 48, 43, 13, 29, 27, 15, … (length 14); φ(49) = 42, and the cycle length 14 divides 42

  1. 1

    Euler's theorem needs φ(49)\varphi(49). What is it?

    Predict first:
open on YouTube

Example 24.5

AMC 10

What is the hundreds digit of 201120112011^{2011}?

Clock dial (its total is revealed at the end of the example)

mod m1000
a2011
power b2011
?0 (mod 1000)
The big numbers
201120112011^{2011} ≡ ? (hidden until the end of the example) (mod 1000)
Swap in the remainders first
112011^{2011} ≡ ? (hidden until the end of the example) (mod 1000)

Same spot on the dial! You never needed the big numbers.

?

a to the b (mod 1000)

  1. 1

    Only the last three digits matter, so work mod 10001000. What is 2011 mod 10002011 \bmod 1000?

    Predict first:
open on YouTube

Try it

Problem 24.1.3

Omega Learn

Find the remainder when 78037^{803} is divided by 400400.

Contest cornerreal contest problems

Problem 24.1.4

AMC 10

An integer NN is selected at random in the range 1≤N≤20201 \le N \le 2020. What is the probability that the remainder when N16N^{16} is divided by 55 is 11?

Click a choice or type its letter (A–E).

Problem 24.1.11

AMC 10

Let a1,a2,…,a2018a_1, a_2, \dots, a_{2018} be a strictly increasing sequence of positive integers such that

a1+a2+⋯+a2018=20182018.a_1 + a_2 + \cdots + a_{2018} = 2018^{2018}.

What is the remainder when a13+a23+⋯+a20183a_1^3 + a_2^3 + \cdots + a_{2018}^3 is divided by 66?

Problem 24.1.26(additional)

AMC 10/12Challenge

The number obtained from the last two nonzero digits of 90!90! is equal to nn. What is nn?

Checkpoint for section 24.0b

Get 2 of 3 right to master this section. One try each, no hints.
1

Compute φ(100)\varphi(100).

2

Find the inverse of 33 modulo 1111: the number xx from 00 to 1010 with 3x≡1(mod11)3x \equiv 1 \pmod{11}.

3

What is the remainder when 10!10! is divided by 1111?

24.0c0%

CRT and Linear Congruences

In this section you will be able to solve systems of congruences with the Chinese Remainder Theorem, by guess and check or by algebra.

open on YouTube

Find a number above 100100 that leaves remainder 55 when divided by 99 and remainder 44 when divided by 1717. Guessing works, but there is a faster way.

Each congruence picks out every mm-th number. When the moduli share no factor, the two patterns line up exactly once in every m1m2m_1 m_2 numbers. That is the Chinese Remainder Theorem.

Look: to solve it by algebra, write n=9k+5n = 9k + 5 and put that into the second congruence. You only need one inverse.

Exploreplay first, formulas later

100 to 199, x ≡ 5 (mod 9) and ≡ 4 (mod 17): 140; together: x ≡ 140 (mod 153)

remainder 15
mod 19
remainder 24
mod 217
140

100 to 199, x ≡ 5 (mod 9) and ≡ 4 (mod 17): 140; together: x ≡ 140 (mod 153)

Name it

Theorem 24.0.11 · Chinese Remainder Theorem

If a positive number xx satisfies

x≡a1(modn1),x≡a2(modn2),…,x≡ak(modnk),x \equiv a_1 \pmod{n_1},\quad x \equiv a_2 \pmod{n_2},\quad \dots,\quad x \equiv a_k \pmod{n_k},

where the nin_i are pairwise relatively prime, then xx has a unique solution modulo n1n2⋯nkn_1 n_2 \cdots n_k.

Remark 24.0.12

Be careful! This may fail if some nin_i share a common factor: the congruences might contradict each other. For example, x≡1(mod4)x \equiv 1 \pmod 4 says xx is odd, while x≡2(mod6)x \equiv 2 \pmod 6 says xx is even.

Concept 24.0.13 · Solving Linear Congruences

To solve a pair of congruences you can either guess and check until a number satisfies both, or use the algebraic method:

  1. Start with n≡r1(modm1)n \equiv r_1 \pmod{m_1} and n≡r2(modm2)n \equiv r_2 \pmod{m_2}, with m1m_1 and m2m_2 relatively prime.
  2. Rewrite the first algebraically: n=km1+r1n = k m_1 + r_1.
  3. Put it into the second: km1+r1≡r2(modm2)k m_1 + r_1 \equiv r_2 \pmod{m_2}, so k≡(r2−r1)⋅m1−1(modm2)k \equiv (r_2 - r_1)\cdot m_1^{-1} \pmod{m_2}.
  4. Find m1−1(modm2)m_1^{-1} \pmod{m_2} by guess and check.
  5. Now you know k≡k0(modm2)k \equiv k_0 \pmod{m_2}; write k=m2t+k0k = m_2 t + k_0.
  6. Substitute back into n=km1+r1n = k m_1 + r_1.
  7. Read off the final congruence n≡k0m1+r1(modm1m2)n \equiv k_0 m_1 + r_1 \pmod{m_1 m_2}.

(The book's step 3 reads “m1≡(r2−r1)⋅k−1m_1 \equiv (r_2 - r_1)\cdot k^{-1}”, and step 5 uses undefined letters b,db, d; fixed here.)

9⁻¹ ≡ 2 (mod 17); 9 × 2 = 18 ≡ 1 (mod 17)

mod m17
a9
012345678910111213141516
Hop by a until you land on 1
9 × 2 = 18 ≡ 1 (mod 17)
9−19^{-1} ≡ 2 (mod 17)
9⁻¹ ≡ 2 (mod 17)

9⁻¹ ≡ 2 (mod 17); 9 × 2 = 18 ≡ 1 (mod 17)

Concept 24.0.14 · The Two-Congruence Formula

For relatively prime m1,m2m_1, m_2, the solution of n≡r1(modm1)n \equiv r_1 \pmod{m_1} and n≡r2(modm2)n \equiv r_2 \pmod{m_2} is

n≡r1+m1(r2−r1)⋅i(modm1m2),where i≡m1−1(modm2).n \equiv r_1 + m_1 (r_2 - r_1)\cdot i \pmod{m_1 m_2}, \qquad \text{where } i \equiv m_1^{-1} \pmod{m_2}.

(The book leaves out the final modulus m1m2m_1 m_2.)

Remark 24.0.15

To solve more than two congruences, solve them two at a time until only one congruence is left.

Watch itpredict, then reveal

Example 24.6

Omega Learn

Find the smallest positive integer greater than 100100 that leaves a remainder of 55 when divided by 99 and leaves a remainder of 44 when divided by 1717.

Congruence sieve (its total is revealed at the end of the example)

remainder 15
mod 19
remainder 24
mod 217
? (hidden until the end of the example)

Numbers 100 to 199

  1. 1

    Write n=9k+5n = 9k + 5. The second condition says 9k+5≡4(mod17)9k + 5 \equiv 4 \pmod{17}. So 9k≡?(mod17)9k \equiv ? \pmod{17} (use a remainder from 00 to 1616)

    Predict first:
open on YouTube

Example 24.7

AIME

The positive integers NN and N2N^2 both end in the same sequence of four digits abcdabcd when written in base 1010, where digit aa is not zero. Find the three-digit number abcabc.

Congruence sieve (its total is revealed at the end of the example)

remainder 10
mod 116
? (hidden until the end of the example)

Numbers 9300 to 9399

  1. 1

    Write the condition as a congruence. What must N(N−1)N(N - 1) be divisible by?

    Predict first:
open on YouTube

Try it

Problem 24.1.6

Omega Learn

Find the smallest positive number that leaves a remainder of 1111 when divided by 1313 and a remainder of 22 when divided by 55.

Contest cornerreal contest problems

Problem 24.1.20(additional)

AMC 10

Let nn be a 55-digit number, and let qq and rr be the quotient and the remainder, respectively, when nn is divided by 100100. For how many values of nn is q+rq + r divisible by 1111?

Problem 24.1.15

AMC 12

Let SS be the set of all integers z>1z > 1 such that for all pairs of nonnegative integers (x,y)(x, y) with x<y<zx < y < z, the remainder when 2025x2025x is divided by zz is less than the remainder when 2025y2025y is divided by zz. What is the sum of the elements of SS?

Checkpoint for section 24.0c

Get 2 of 3 right to master this section. One try each, no hints.
1

Find the smallest positive nn with n≡2(mod3)n \equiv 2 \pmod 3 and n≡3(mod5)n \equiv 3 \pmod 5.

2

How many integers xx with 0≤x<120 \le x < 12 satisfy both x≡1(mod4)x \equiv 1 \pmod 4 and x≡2(mod6)x \equiv 2 \pmod 6?

3

Find the smallest n>1n > 1 that leaves remainder 11 when divided by 77 and by 1111.

24.1

Practice Problems

In this section you will be able to mix every tool of the chapter on contest problems.

The rest of the practice set, from AMC 10 warm-ups to AIME 13s. First ask: which modulus makes the problem small?

Contest cornerreal contest problems

Problem 24.1.5

PUMaC

If pp, qq and rr are primes with pqr=7(p+q+r)pqr = 7(p + q + r), find p+q+rp + q + r.

Problem 24.1.7

AMC 10

This problem also appears in the book as 21.3.21.

What is the hundreds digit of (20!−15!)(20! - 15!)?

Problem 24.1.8

AMC 10

This problem also appears in the book as 21.3.19.

What is the tens digit of 20152016−20172015^{2016} - 2017?

Problem 24.1.9

AMC 10

Which of the following expressions is never a prime number when pp is a prime number?

Click a choice or type its letter (A–E).

Problem 24.1.10

AMC 12

Let S(n)S(n) equal the sum of the digits of positive integer nn. For example, S(1507)=13S(1507) = 13. For a particular positive integer nn, S(n)=1274S(n) = 1274. Which of the following could be the value of S(n+1)S(n+1)?

Click a choice or type its letter (A–E).

Problem 24.1.13

AMC 12

This problem also appears in the book as 21.3.20.

Let N=123456789101112…4344N = 123456789101112\dots4344 be the 7979-digit number that is formed by writing the integers from 11 to 4444 in order, one after the other. What is the remainder when NN is divided by 4545?

Problem 24.1.14

AMC 10/12

One of the following numbers is not divisible by any prime number less than 1010. Which is it?

Click a choice or type its letter (A–E).

Problem 24.1.16

AIME

Let pp be the least prime number for which there exists a positive integer nn such that n4+1n^4 + 1 is divisible by p2p^2. Find the least positive integer mm such that m4+1m^4 + 1 is divisible by p2p^2.

Problem 24.1.17

AMC 10/12Challenge

Let x0,x1,x2,…x_0, x_1, x_2, \dots be a sequence of numbers, where each xkx_k is either 00 or 11. For each positive integer nn, define

Sn=∑k=0n−1xk2k.S_n = \sum_{k=0}^{n-1} x_k 2^k.

Suppose 7Sn≡1(mod2n)7S_n \equiv 1 \pmod{2^n} for all n≥1n \ge 1. What is the value of the sum

x2019+2x2020+4x2021+8x2022?x_{2019} + 2x_{2020} + 4x_{2021} + 8x_{2022}?
Click a choice or type its letter (A–E).

Problem 24.1.19(additional)

AMC 10

What is the greatest power of 22 that is a factor of 101002−450110^{1002} - 4^{501}?

Click a choice or type its letter (A–E).

Problem 24.1.22(additional)

AIME

For positive integers NN and kk, define NN to be kk-nice if there exists a positive integer aa such that aka^k has exactly NN positive divisors. Find the number of positive integers less than 10001000 that are neither 77-nice nor 88-nice.

Problem 24.1.23(additional)

AIME

Let SS be the set of integers between 11 and 2402^{40} whose binary expansions have exactly two 11's. If a number is chosen at random from SS, the probability that it is divisible by 99 is p/qp/q, where pp and qq are relatively prime positive integers. Find p+qp + q.

Problem 24.1.24(additional)

AIME

It is known that, for all positive integers kk,

12+22+32+⋯+k2=k(k+1)(2k+1)6.1^2 + 2^2 + 3^2 + \cdots + k^2 = \frac{k(k+1)(2k+1)}{6}.

Find the smallest positive integer kk such that 12+22+32+⋯+k21^2 + 2^2 + 3^2 + \cdots + k^2 is a multiple of 200200.

Problem 24.1.25(additional)

AIME

Find the sum of all positive integers nn such that when 13+23+33+⋯+n31^3 + 2^3 + 3^3 + \cdots + n^3 is divided by n+5n + 5, the remainder is 1717.