Apprentissage des Mathématiques

Math Playgrounds

Interactive tools to explore and discover mathematical concepts through hands-on experimentation

Welcome to the Math Playgrounds! These interactive tools let you experiment with mathematical concepts, see patterns emerge, and discover relationships through exploration. Each playground is designed to help you understand the "why" behind the math, not just the "what".

Caesar Cipher Encryptor

Build it first! Encrypt messages by shifting each letter. This is Day 1-2 of the Encryption Project. Try "HELLO" with shift 3 to get "KHOOR"!

Caesar Cipher Encryptor

Encrypt text by shifting each letter. Try "HELLO" with shift 3 to get "KHOOR"!

3

Alphabet Wheel (Shift = 3)

A
D
B
E
C
F
D
G
E
H
F
I
G
J
H
K
I
L
J
M
K
N
L
O
M
P
N
Q
O
R
P
S
Q
T
R
U
S
V
T
W
U
X
V
Y
W
Z
X
A
Y
B
Z
C

Each letter shifts 3 positions forward

Step-by-Step Encryption

HK(7 + 3 = 10 mod 26 = 10)
EH(4 + 3 = 7 mod 26 = 7)
LO(11 + 3 = 14 mod 26 = 14)
LO(11 + 3 = 14 mod 26 = 14)
OR(14 + 3 = 17 mod 26 = 17)
Encrypted Text

KHOOR

💡 Try these examples:



Affine Cipher Encryptor/Decryptor

Week 2: Affine Cipher (Harder). Use formula (ax + b) mod 26. Key requirement: gcd(a, 26) = 1.

Affine Cipher Encryptor/Decryptor

Encrypt using formula: (ax + b) mod 26. Key requirement: gcd(a, 26) = 1

Modular Inverse of 5:5-1 mod 26 = 21
Encryption Formula:(5x + 8) mod 26

Step-by-Step Encryption

HR
5 × 7 + 8 = 43 mod 26 = 17
EC
5 × 4 + 8 = 28 mod 26 = 2
LL
5 × 11 + 8 = 63 mod 26 = 11
LL
5 × 11 + 8 = 63 mod 26 = 11
OA
5 × 14 + 8 = 78 mod 26 = 0
Encrypted Text

RCLLA

Decrypted (verification)

HELLO

Decrypt formula: (y - 8) × 21 mod 26

💡 Valid values for a (gcd(a, 26) = 1):

Mini-RSA Encryption/Decryption

Week 3: Mini-RSA. Use RSA with small numbers. Choose two primes p and q, then encrypt/decrypt messages.

Mini-RSA Encryption/Decryption

RSA encryption with small numbers. Choose two primes p and q, then select public key e.

n = p × q:61 × 53 = 3233
φ(n) = (p-1)(q-1):(61-1)(53-1) = 3120
Public Key (e, n):(17, 3233)
Private Key d:2753 (e-1 mod φ(n))

Encryption Steps

1. Message: m = 123
2. Encrypt: c = me mod n
3. Calculate: c = 12317 mod 3233
4. Result: c = 855

Decryption Steps

1. Ciphertext: c = 855
2. Decrypt: m = cd mod n
3. Calculate: m = 8552753 mod 3233
4. Result: m = 123✓ Matches original!
Encrypted Ciphertext

855

Decrypted Message (verification)

123

✓ Successfully decrypted! Original message recovered.

🔒 Security Note:

This uses small numbers for learning. Real RSA uses primes with hundreds of digits. The security comes from the difficulty of factoring n = p × q when p and q are very large.

Divisibility Rules Tester

Week 1: Divisibility Rules. Test numbers against divisibility rules and find missing digits.

Divisibility Rules Tester

Test numbers against divisibility rules. Learn why each rule works!

Result

4572 is divisible by 9

Sum of digits (18) is divisible by 9

1. Sum of digits: 4 + 5 + 7 + 2 = 18

2. 18 is divisible by 9

Find Missing Digit Problem

The number 45_72 is divisible by 9. What is the missing digit?

Check Digit Validator

Week 2: Check Digits (Real-World). Validate credit cards (Luhn Algorithm) and ISBN numbers.

Check Digit Validator

Validate credit cards (Luhn Algorithm) and ISBN numbers. Learn how check digits work!

Enter 15 digits (we'll calculate the 16th check digit)

Check Digit: 8

Complete number: 4532148803436468

Starting with: 453214880343646

Position 15 (from right): 6 (unchanged)

Position 14 (from right): 4 × 2 = 8

Position 13 (from right): 6 (unchanged)

Position 12 (from right): 3 × 2 = 6

Position 11 (from right): 4 (unchanged)

Position 10 (from right): 3 × 2 = 6

Position 9 (from right): 0 (unchanged)

Position 8 (from right): 8 × 2 = 16 → 16 - 9 = 7

Position 7 (from right): 8 (unchanged)

Position 6 (from right): 4 × 2 = 8

Position 5 (from right): 1 (unchanged)

Position 4 (from right): 2 × 2 = 4

Position 3 (from right): 3 (unchanged)

Position 2 (from right): 5 × 2 = 10 → 10 - 9 = 1

Position 1 (from right): 4 (unchanged)

After doubling: 413418870646686

Sum: 4 + 1 + 3 + 4 + 1 + 8 + 8 + 7 + 0 + 6 + 4 + 6 + 6 + 8 + 6 = 72

Check digit: (10 - 2) mod 10 = 8

Validation: 72 mod 10 = 2 → Invalid

💡 Try these examples:


Sieve of Eratosthenes

Week 1: Finding Primes. Watch the Sieve of Eratosthenes mark composite numbers and reveal primes!

Sieve of Eratosthenes

Find all prime numbers up to a given range. Watch as composite numbers are marked!

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Prime
Composite
Current step
Unmarked
Primes found: 0

💡 How it works:

  1. 1. Start with 2 (first prime)
  2. 2. Mark all multiples of 2 as composite
  3. 3. Move to next unmarked number (3)
  4. 4. Mark all its multiples as composite
  5. 5. Repeat until you've checked up to √n
  6. 6. All remaining unmarked numbers are prime!

Primality Testing

Week 2: Testing Large Primes. Use Fermat's test and Miller-Rabin test to check if large numbers are prime.

Primality Testing

Test large numbers for primality using Fermat's test or Miller-Rabin test.

561 is probably prime

Actual result: Composite⚠️ Test was wrong!

Testing if 561 is prime using Fermat's Little Theorem

Base: 2

Fermat's Little Theorem: If 561 is prime, then 2^560 ≡ 1 (mod 561)

Calculate: 2^560 mod 561

Result: 1

1 = 1 → Probably prime

⚠️ Warning: 561 is a Carmichael number! Fermat's test can be fooled.

💡 Try these examples:



📚 Notes:

  • • Fermat's test can be fooled by Carmichael numbers (like 561)
  • • Miller-Rabin is more reliable and used in real cryptography
  • • For large numbers, run multiple tests with different bases

Prime Patterns Explorer

Week 3: Prime Patterns. Explore twin primes and prime gaps. Discover unsolved mysteries!

Prime Patterns Explorer

Explore fascinating patterns in prime numbers: twin primes and prime gaps.

Twin Primes Found: 0(pairs where difference = 2)

🔬 Unsolved Problem:

Are there infinitely many twin primes? This is one of the most famous unsolved problems in mathematics!

Emergency 1-Day Crash Course

Quick visualizations for the 4-hour crash course. Master the essentials!

Hour 1: Modular Arithmetic Basics

Clock arithmetic: 15 mod 12 = 3, 23 mod 7 = 2. Practice 20 problems.

Result

23 mod 7 = 2

Calculation Steps:

1. Divide 23 by 7

2. 23 = 3 × 7 + 2

3. Remainder: 2

23 mod 7 = 2

0123456

💡 Try exploring:

  • • Try negative numbers: -5 mod 12
  • • Try large numbers: 100 mod 7
  • • Change the modulus and see how the clock changes
  • • Notice patterns: (a + b) mod m = ((a mod m) + (b mod m)) mod m

Hour 2: GCD and Euclidean Algorithm

Learn gcd(48, 18) step-by-step. Practice 10 problems.

GCD Calculator (Euclidean Algorithm)

Find the Greatest Common Divisor using the Euclidean Algorithm. Learn step-by-step!

GCD Result

gcd(48, 18) = 6

Euclidean Algorithm Steps

48 = 2 × 18 + 12

Divide 48 by 18: quotient = 2, remainder = 12

18 = 1 × 12 + 6

Divide 18 by 12: quotient = 1, remainder = 6

12 = 2 × 6 + 0

Divide 12 by 6: quotient = 2, remainder = 0

✓ Remainder is 0! GCD = 6

Why This Works

The key insight: gcd(a, b) = gcd(b, a mod b)

If d divides both a and b, then d also divides (a mod b). So we can replace a with b and b with (a mod b), making the numbers smaller each step until we reach 0.

💡 Try these examples:



Hour 3: Modular Inverses

Find x where (5x) mod 26 = 1 using Extended Euclidean Algorithm. Practice 10 problems.

Modular Inverse Calculator

Find the modular inverse using Extended Euclidean Algorithm. The inverse of a mod m is the number x such that (a × x) mod m = 1.

gcd(5, 26) = 1

✓ gcd = 1, so inverse exists!

Modular Inverse

5-1 mod 26 = 21

Verification: (5 × 21) mod 26 = 1

Extended Euclidean Algorithm Steps

Find gcd(5, 26) and coefficients x, y such that 5x + 26y = gcd(5, 26)

Initial: r₀ = 5, r₁ = 26, s₀ = 1, s₁ = 0, t₀ = 0, t₁ = 1

Step 1:

q = ⌊5 / 26⌋ = 0

r₂ = 5 - 0 × 26 = 5

s₂ = 1 - 0 × 0 = 1

t₂ = 0 - 0 × 1 = 0

Step 2:

q = ⌊26 / 5⌋ = 5

r₂ = 26 - 5 × 5 = 1

s₂ = 0 - 5 × 1 = -5

t₂ = 1 - 5 × 0 = 1

Step 3:

q = ⌊5 / 1⌋ = 5

r₂ = 5 - 5 × 1 = 0

s₂ = 1 - 5 × -5 = 26

t₂ = 0 - 5 × 1 = -5

Final: gcd(5, 26) = 1

Coefficients: 5 × -5 + 26 × 1 = 1

From Extended Euclidean Algorithm:

5 × -5 + 26 × 1 = 1

So: 5 × -5 ≡ 1 (mod 26)

Therefore: 5-1 mod 26 = -5 mod 26 = 21

💡 Try these examples:



More Playgrounds Coming Soon

Prime Factorization

Interactive prime factorization with tree visualization.

Coming soon