Aprendizado de Matemática

Number Theory Projects

Top-down learning projects for beginners

Choose from 3 beginner-friendly number theory projects. Pick one, and learn ONLY the math you need for that project. Each project includes week-by-week breakdowns with code examples and step-by-step instructions.

Project Options

Select a project to get started

Build a Simple Encryption System 🔐

Create a program that encrypts and decrypts messages using modular arithmetic. Progress from simple Caesar cipher to advanced mini-RSA encryption.

Learning Path

Caesar Cipher → Affine Cipher → Mini-RSA

Time Required

2-3 weeks (5 hours/week)

Topics Covered
Modular arithmeticGCDModular inversesPrime number properties
Week-by-Week Breakdown

Week 1: Caesar Cipher

Build it first, then learn the math. Break it to understand security.

Day 1-2: Build it first

Encrypt: shift each letter by 3. 'HELLO' → 'KHOOR'. Write the code - don't worry about math yet.

Day 3-4: Now learn the math

This is modular arithmetic: (H + 3) mod 26. Learn: What is 'mod'? Practice: Calculate 17 mod 5, 23 mod 7.

Day 5-7: Break it

Try all 26 possible shifts. Learn: Why is this insecure?

Week 2: Affine Cipher (Harder)

Use the formula, learn why it works, and implement decryption.

Day 1-2: Use the formula

Encrypt: (ax + b) mod 26. Example: a=5, b=8. 'HELLO' → ?

Day 3-4: Learn why it works

Why must gcd(a, 26) = 1? Learn: GCD using Euclidean algorithm. Practice: Find gcd(15, 26), gcd(5, 26).

Day 5-7: Decrypt

Need to find modular inverse. Learn: Extended Euclidean algorithm. Practice: Find inverse of 5 mod 26.

Week 3: Mini-RSA

Use RSA with small numbers, learn Euler's totient function, implement full RSA.

Day 1-3: Use RSA with small numbers

Given: p = 61, q = 53, n = 3233, e = 17. Encrypt message m = 123: c = (123^17) mod 3233 = ?

Day 4-5: Learn the math

Why multiply two primes? What is Euler's totient function φ(n)? Learn: (p-1)(q-1) when n = pq.

Day 6-7: Implement full RSA

Generate keys. Encrypt/decrypt. Understand why it's secure.

Solve 'Divisibility Detective' Problems 🔍

Build a program that solves puzzles like finding missing digits and validates real-world numbers like credit cards and ISBNs using divisibility rules and check digit algorithms.

Learning Path

Divisibility Rules → Check Digit Algorithms → Universal Validator

Time Required

2 weeks (4 hours/week)

Topics Covered
Divisibility rulesModular arithmeticCheck digit algorithms
Week-by-Week Breakdown

Week 1: Divisibility Rules

Learn divisibility by 9, other rules (2, 3, 4, 5, 6, 8, 9, 10, 11), and build a solver.

Day 1: The Problem

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

Day 2-3: Learn divisibility by 9

Rule: Sum of digits must be divisible by 9. Why? Learn about mod 9 arithmetic. Practice: 10 similar problems.

Day 4-5: Other divisibility rules

Divisibility by 2, 3, 4, 5, 6, 8, 9, 10, 11. Learn the patterns. Practice: Mixed problems.

Day 6-7: Build a solver

def find_missing_digit(number_string, divisor): # Your code here

Week 2: Check Digits (Real-World)

Credit cards (Luhn Algorithm), ISBN numbers, and build a universal validator.

Day 1-2: Credit Cards (Luhn Algorithm)

Credit card: 4532 1488 0343 6467. Is it valid? Learn the algorithm. Implement it. Test with real card numbers (last digit).

Day 3-4: ISBN Numbers

Book ISBN: 0-306-40615-?. Calculate the check digit. Learn ISBN-10 algorithm. Uses mod 11. Implement it.

Day 5-7: Build a Universal Validator

def validate(number, algorithm): # Supports: Luhn, ISBN, UPC, etc.

Prime Number Explorer 🔢

Create a program that finds prime numbers, tests primality efficiently, and visualizes fascinating prime patterns and relationships.

Learning Path

Finding Primes → Testing Large Primes → Exploring Prime Patterns

Time Required

2-3 weeks (4 hours/week)

Topics Covered
Prime propertiesPrimality testingPrime patterns
Week-by-Week Breakdown

Week 1: Finding Primes

Brute force, optimize, and implement Sieve of Eratosthenes.

Day 1-2: Brute Force

def is_prime(n): # Check if n is divisible by any number from 2 to n-1. Write this first.

Day 3-4: Optimize

Only check up to √n. Why does this work? Learn: If n = a × b, one of them is ≤ √n.

Day 5-7: Sieve of Eratosthenes

Find all primes up to 1,000,000. Learn the algorithm. Implement it. Visualize the pattern.

Week 2: Testing Large Primes

Fermat's test, Miller-Rabin test, test with huge numbers.

Day 1-3: Fermat's Test

Is 561 prime? Test: 2^560 mod 561 = ? Learn Fermat's Little Theorem. Implement the test. Discover it can be fooled (Carmichael numbers).

Day 4-7: Miller-Rabin Test

More reliable primality test. Used in real cryptography. Implement it. Test with huge numbers (100+ digits).

Week 3: Prime Patterns

Twin primes, prime gaps, visualize patterns.

Day 1-3: Twin Primes

Find pairs like (11, 13), (17, 19). Are there infinitely many? (Unsolved!) Visualize them.

Day 4-7: Prime Gaps

Distance between consecutive primes. Plot the gaps. Find patterns.

Quick Start Guide

Emergency crash course for immediate learning

Emergency 1-Day Crash Course 🚨

A 4-hour intensive course covering: Modular arithmetic basics, GCD and Euclidean algorithm, Modular inverses, and applying to your problem.

Time Required

4 hours

Hour-by-Hour Breakdown

Hour 1: Modular Arithmetic Basics

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

Try Playground

Hour 2: GCD and Euclidean Algorithm

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

Try Playground

Hour 3: Modular Inverses

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

Try Playground

Hour 4: Apply to Your Problem

Use what you learned, solve your specific problem, look up anything else you need.