A collection of my solutions to the first 100 Project Euler problems, written in Python.
The goal of this project isn't just to get the correct answers—it's also an opportunity to practice writing clean, reusable, and reasonably efficient code while learning new algorithms and mathematical techniques.
Current Progress: 75 / 100 ✅
██████████████████████████████████████░░░░░░░░░░░░ 75%
Note
This project may occasionally surprise you. If you prefer perfectly reproducible output, use
--no-easter-eggs.
- Solutions organized inside a single
EulerSolverclass - Reusable helper functions for common mathematical operations
- Automatic discovery of implemented problems
- Command-line interface powered by
argparse - Run individual Project Euler problems
- List all implemented problems
- Animated loading spinners using Halo
- Colored terminal output using Colorama
- Execution time displayed for computationally intensive problems
- Clean and readable code with docstrings
- Modular package structure (
euler_problems/) split by responsibility for easier maintenance
| Problem | Description | Status |
|---|---|---|
| 0 | Sum of odd perfect squares up to 756000 | ✅ |
| 1 | Multiples of 3 or 5 | ✅ |
| 2 | Even Fibonacci Numbers | ✅ |
| 3 | Largest Prime Factor | ✅ |
| 4 | Largest Palindrome Product | ✅ |
| 5 | ✦ Smallest Multiple | ✅ |
| 6 | Sum Square Difference | ✅ |
| 7 | 10,001st Prime | ✅ |
| 8 | Largest Product in a Series | ✅ |
| 9 | Special Pythagorean Triplet | ✅ |
| 10 | Summation of Primes | ✅ |
| 11 | Largest Product in a Grid | ✅ |
| 12 | Highly Divisible Triangular Number | ✅ |
| 13 | Large Sum | ✅ |
| 14 | Longest Collatz Sequence | ✅ |
| 15 | Lattice Paths | ✅ |
| 16 | Power Digit Sum | ✅ |
| 17 | Number Letter Counts | ✅ |
| 18 | Maximum Path Sum I | ✅ |
| 19 | Counting Sundays | ✅ |
| 20 | Factorial Digit Sum | ✅ |
| 21 | Amicable Numbers | ✅ |
| 22 | Names Scores | ✅ |
| 23 | Non-Abundant Sums | ✅ |
| 24 | Lexicographic Permutations | ✅ |
| 25 | 1000-digit Fibonacci Number | ✅ |
| 26 | Reciprocal Cycles | ✅ |
| 27 | Quadratic Primes | ✅ |
| 28 | Number Spiral Diagonals | ✅ |
| 29 | Distinct Powers | ✅ |
| 30 | Digit Fifth Powers | ✅ |
| 31 | Coin Sums | ✅ |
| 32 | Pandigital Products | ✅ |
| 33 | Digit Cancelling Fractions | ✅ |
| 34 | Digit Factorials | ✅ |
| 35 | Circular Primes | ✅ |
| 36 | Double-base Palindromes | ✅ |
| 37 | ✦ Truncatable Primes | ✅ |
| 38 | Pandigital Multiples | ✅ |
| 39 | ✦ Integer Right Triangles | ✅ |
| 40 | Champernowne's Constant | ✅ |
| 41 | Pandigital Prime | ✅ |
| 42 | Coded Triangle Numbers | ✅ |
| 43 | Sub-string Divisibility | ✅ |
| 44 | Pentagon Numbers | ✅ |
| 45 | Triangular, Pentagonal, and Hexagonal | ✅ |
| 46 | Goldbach's Other Conjecture | ✅ |
| 47 | Distinct Primes Factors | ✅ |
| 48 | Self Powers | ✅ |
| 49 | Prime Permutations | ✅ |
| 50 | Consecutive Prime Sum | ✅ |
| 51 | Prime Digit Replacements | ✅ |
| 52 | Permuted Multiples | ✅ |
| 53 | Combinatoric Selections | ✅ |
| 54 | Poker Hands | ✅ |
| 55 | Lychrel Numbers | ✅ |
| 56 | Powerful Digit Sum | ✅ |
| 57 | Square Root Convergents | ✅ |
| 58 | Spiral Primes | ✅ |
| 59 | XOR Decryption | ✅ |
| 60 | Prime Pair Sets | ✅ |
| 61 | Cyclical Figurate Numbers | ✅ |
| 62 | Cubic Permutations | ✅ |
| 63 | Powerful Digit Counts | ✅ |
| 64 | Odd Period Square Roots | ✅ |
| 65 | Convergents of e | ✅ |
| 66 | Diophantine Equation | ✅ |
| 67 | Maximum Path Sum II | ✅ |
| 68 | Magic 5-gon Ring | ✅ |
| 69 | Totient Maximum | ✅ |
| 70 | Totient Permutation | ✅ |
| 71 | Ordered Fractions | ✅ |
| 72 | Counting Fractions | ✅ |
| 73 | Counting Fractions in a Range | ✅ |
| 74 | Digit Factorial Chains | ✅ |
| 75 | Singular Integer Right Triangles | ✅ |
✦ Some solved problems contain optional surprises.
Note: Problem 0 is the starting challenge for account creation
EulerProblems.py (Thin entry point - run this, same CLI as always)
euler_problems/ (Package containing all solver logic)
__init__.py (Dependency check + package exports)
exceptions.py (Custom exception hierarchy)
data.py (Large static data blobs - problems 8, 11, 13, 18)
helpers.py (CLI/output helpers - spinners, progress bar, etc.)
utils.py (Reusable math helper functions)
easter_eggs.py (Hidden easter egg behavior)
problems_00_25.py (Solutions: problem0 - problem25)
problems_26_50.py (Solutions: problem26 - problem50)
problems_51_75.py (Solutions: problem51 - problem75)
solver.py (EulerSolver class, combining everything above)
cli.py (argparse setup + main entry point)
0022_names.txt (The names for Problem 22)
0042_words.txt (The words for Problem 42)
0054_poker.txt (The poker hands for Problem 54)
0059_cipher.txt (The encrypted message for Problem 59)
0067_triangle.txt (The triangle for Problem 67)
README.md (This file)
LICENSE.txt (The MIT License)
This project used to live entirely inside one ~3,100-line file. It's now split
across the euler_problems/ package, with each piece combined into a single
EulerSolver class via mixins:
- Utility/helper methods →
helpers.py,utils.py - Hidden easter eggs →
easter_eggs.py - Individual Project Euler solutions →
problems_00_25.py,problems_26_50.py,problems_51_75.py - Runner / CLI →
solver.py,cli.py
Nothing changes about how you run it - python EulerProblems.py ... still works
exactly like before; it's now just a thin entry point into the package.
Python 3.11+ is recommended.
Install dependencies:
pip install colorama haloPrints out a help message:
python EulerProblems.pyRun every implemented Project Euler solution:
python EulerProblems.py --allExecute one or more individual problems by specifying their numbers.
python EulerProblems.py 1python EulerProblems.py 1 5 10 15View every currently implemented Project Euler problem.
python EulerProblems.py --listor
python EulerProblems.py -lExample output:
Implemented Problems
0 - Find the sum of all odd perfect squares up to 756000
1 - Find the sum of all multiples of 3 or 5 below 1000
2 - Find the sum of all even Fibonacci numbers below 4 million
...
XX - Latest implemented problem
Many Project Euler problems reuse common algorithms. Instead of rewriting code, helper methods are shared across multiple solutions.
Current helper functionality includes:
- Prime number generation
- Sieve of Eratosthenes
- Prime factorization
- Fibonacci generation
- Palindrome checking
- Divisor counting
- Triangle number generation
- Grid searching
- Integer-to-English conversion
- Leap year calculations
- Date calculations
- Dynamic programming
- Mathematical utilities
- And more as new problems require them.
Finish all 100 Project Euler problems while continually improving:
- Python knowledge
- Algorithm design
- Mathematical problem solving
- Runtime efficiency
- Code readability
- Command-line interface
- Run individual problems
- List implemented problems
- Benchmark mode
- Automatic answer verification against Project Euler answers
- Export benchmark results to CSV
- Unit tests
- More optimized algorithms for later problems
- Progress statistics
- Separate helper functions into their own module
- Split codebase into multiple modules
Project Euler offers problems that combine mathematics with programming. Rather than simply obtaining the correct answer, this project focuses on writing solutions that are:
- Readable
- Reusable
- Efficient
- Well documented
- Easy to benchmark and improve over time
Every solved problem is another opportunity to learn something new.
This project contains a handful of hidden easter eggs for those who are lucky enough to find them.
By default, easter eggs have a small chance of appearing during the execution of certain Project Euler problems.
If you would like deterministic output for benchmarking, screenshots, or automated testing, you can disable them:
python EulerProblems.py --no-easter-eggsHint: At least one easter egg is hidden in Problem 39...
This project is released under the MIT License.