1.
Introduction
2.
Project Euler
❱
2.1.
Problem 1: Multiples of 3 or 5
❱
2.1.1.
Brute force
2.1.2.
Three by three
2.1.3.
Summing everything
2.1.4.
Solution
2.2.
Problem 2: even Fibonacci numbers
❱
2.2.1.
Brute force
2.2.2.
Fibonacci recurrence
2.2.3.
Fibonacci and the golden ratio
2.2.4.
Solution
2.3.
Problem 3: Largest prime factor
❱
2.3.1.
Brute force
2.3.2.
Two by two
2.3.3.
Solution
2.4.
Problem 4: Largest palindrome product
❱
2.4.1.
Brute force
2.4.2.
Factorisation is the key
2.4.3.
With pen and paper
2.4.4.
Solution
2.5.
Problem 5: Smallest multiple
❱
2.5.1.
Brute force
2.5.2.
Prime factorization
2.5.3.
Least common multiple
2.5.4.
Solution
2.6.
Problem 6: Sum square difference
❱
2.6.1.
Brute force
2.6.2.
Summation formula
2.6.3.
Solution
2.7.
Problem 7: 10001st prime
❱
2.7.1.
Brute force
2.7.2.
Almost six by six
2.7.3.
Prime number theorem
2.7.4.
Solution
2.8.
Problem 8: Largest product in a series
❱
2.8.1.
Brute force
2.8.2.
0 are useless
2.8.3.
Solution
2.9.
Problem 9: Special Pythagorean triplet
❱
2.9.1.
Brute force
2.9.2.
With a little thought
2.9.3.
Prime Pythagorean triples
2.9.4.
Solution
2.10.
Problem 10: Summation of primes
❱
2.10.1.
Brute force
2.10.2.
Summation minus summation
2.10.3.
Dynamic programming
2.10.4.
Solution
2.11.
Problem 11: Largest product in a grid
❱
2.11.1.
Brute force
2.11.2.
Solution
2.12.
Problem 12: Highly divisible triangular number
❱
2.12.1.
Brute force
2.12.2.
Common factor
2.12.3.
Solution
2.13.
Problem 13: Large sum
❱
2.13.1.
Brute force
2.13.2.
Solution
2.14.
Problem 14: Longest Collatz sequence
❱
2.14.1.
Brute force
2.14.2.
Caching
2.14.3.
Solution
2.15.
Problem 15: Lattice paths
❱
2.15.1.
Brute force
2.15.2.
Dynamic programming
2.15.3.
Combination
2.15.4.
Solution
2.16.
Problem 16: Power digit sum
❱
2.16.1.
Brute force
2.16.2.
Solution
2.17.
Problem 17: Number letter counts
❱
2.17.1.
Brute force
2.17.2.
Solution
2.18.
Problem 18: Maximum path sum I
❱
2.18.1.
Brute force
2.18.2.
Dynamic programming
2.18.3.
Solution
2.19.
Problem 19: Counting Sundays
❱
2.19.1.
Brute force
2.19.2.
Solution
2.20.
Problem 20: Factorial digit sum
❱
2.20.1.
Brute force
2.20.2.
Solution
2.21.
Problem 21: Amicable numbers
❱
2.21.1.
Brute force
2.21.2.
Solution
2.22.
Problem 22: Names scores
❱
2.22.1.
Brute force
2.22.2.
Solution
2.23.
Problem 23: Non-abundant sums
❱
2.23.1.
Brute force
2.23.2.
Set
2.23.3.
Solution
2.24.
Problem 24: Lexicographic permutations
❱
2.24.1.
Brute force
2.24.2.
Maths permutations
2.24.3.
Solution
2.25.
Problem 25: 1000-digit Fibonacci number
❱
2.25.1.
Brute force
2.25.2.
Fibonacci convergence
2.25.3.
Solution
2.26.
Problem 26: Reciprocal cycles
❱
2.26.1.
Brute force
2.26.2.
Carmichael function
2.26.3.
Solution
2.27.
Problem 27: Quadratic primes
❱
2.27.1.
Brute force
2.27.2.
Shorten the intervals
2.27.3.
Lucky numbers of Euler
2.27.4.
Solution
2.28.
Problem 28: Number spiral diagonals
❱
2.28.1.
Brute force
2.28.2.
Summation
2.28.3.
Solution
2.29.
Problem 29: Distinct powers
❱
2.29.1.
Brute force
2.29.2.
Discarding duplicate
2.29.3.
Solution
2.30.
Problem 30: Digit fifth powers
❱
2.30.1.
Brute force
2.30.2.
Search unique combination
2.30.3.
Solution
2.31.
Problem 31: Coin sums
❱
2.31.1.
Brute force
2.31.2.
Dynamic programming
2.31.3.
Better dynamic programming
2.31.4.
Solution
2.32.
Problem 32: Pandigital products
❱
2.32.1.
Brute force
2.32.2.
Solution
2.33.
Problem 33: Digit cancelling fractions
❱
2.33.1.
Brute force
2.33.2.
Solution
2.34.
Problem 34: Digit factorials
❱
2.34.1.
Brute force
2.34.2.
Solution
2.35.
Problem 35: Circular primes
❱
2.35.1.
Brute force
2.35.2.
1, 3, 7, 9
2.35.3.
Solution
2.36.
Problem 36: Double-base palindromes
❱
2.36.1.
Brute force
2.36.2.
Generating palindromes
2.36.3.
Solution
2.37.
Problem 37: Truncatable primes
❱
2.37.1.
Brute force
2.37.2.
Construct them all
2.37.3.
Solution
2.38.
Problem 38: Pandigital multiples
❱
2.38.1.
Brute force
2.38.2.
Good old pen and paper
2.38.3.
Solution
2.39.
Problem 39: Integer right triangles
❱
2.39.1.
Brute force
2.39.2.
Fewer loops is better
2.39.3.
Even fewer loops
2.39.4.
Tree of primitive Pythagorean triples
2.39.5.
Solution
2.40.
Problem 40: Champernowne's constant
❱
2.40.1.
Brute force
2.40.2.
Foreshadowing
2.40.3.
Solution
2.41.
Problem 41: Pandigital prime
❱
2.41.1.
Brute force
2.41.2.
Solution
2.42.
Problem 42: Coded triangle numbers
❱
2.42.1.
Brute force
2.42.2.
Solution
2.43.
Problem 43: Sub-string divisibility
❱
2.43.1.
Brute force
2.43.2.
Generation over iteration
2.43.3.
With pen and paper
2.43.4.
Solution
2.44.
Problem 44: Pentagon numbers
❱
2.44.1.
Brute force
2.44.2.
Optimal iteration
2.44.3.
Even better iteration
2.44.4.
Solution
2.45.
Problem 45: Triangular, pentagonal, and hexagonal
❱
2.45.1.
Brute force
2.45.2.
Triangular numbers are useless
2.45.3.
Diophantine equations
2.45.4.
Solution
2.46.
Problem 46: Goldbach's other conjecture
❱
2.46.1.
Brute force
2.46.2.
Better iteration and caching
2.46.3.
Solution
2.47.
Problem 47: Distinct primes factors
❱
2.47.1.
Brute force
2.47.2.
Cache is life
2.47.3.
Good old Sieve
2.47.4.
Solution
2.48.
Problem 48: Self powers
❱
2.48.1.
Brute force
2.48.2.
Modulos reduction
2.48.3.
Solution
2.49.
Problem 49: Prime permutations
❱
2.49.1.
Brute force
2.49.2.
Primes permutations
2.49.3.
Solution
2.50.
Problem 50: Consecutive prime sum
❱
2.50.1.
Brute force
2.50.2.
Cumulative sum
2.50.3.
Solution
2.51.
Problem 51: Prime digit replacements
❱
2.51.1.
Brute force
2.51.2.
Simple observations
2.51.3.
Solution
2.52.
Problem 52: Permuted multiples
❱
2.52.1.
Brute force
2.52.2.
Observation is insight
2.52.3.
Solution
2.53.
Problem 53: Combinatoric selections
❱
2.53.1.
Brute force
2.53.2.
Pascal's Triangle
2.53.3.
Solution
2.54.
Problem 54: Poker hands
❱
2.54.1.
Brute force
2.54.2.
Solution
2.55.
Problem 55: Lychrel numbers
❱
2.55.1.
Brute force
2.55.2.
Solution
2.56.
Problem 56: Powerful digit sum
❱
2.56.1.
Brute force
2.56.2.
Solution
2.57.
Problem 57: Square root convergents
❱
2.57.1.
Brute force
2.57.2.
A better recurrence?
2.57.3.
Solution
2.58.
Problem 58: Spiral primes
❱
2.58.1.
Brute force
2.58.2.
Solution
2.59.
Problem 59: XOR decryption
❱
2.59.1.
Brute force
2.59.2.
Solution
2.60.
Problem 60: Prime pair sets
❱
2.60.1.
Brute force
2.60.2.
Clique's graph theory
2.60.3.
Solution
2.61.
Problem 61: Cyclical figurate numbers
❱
2.61.1.
Brute force
2.61.2.
Caching polygonal numbers
2.61.3.
Solution
2.62.
Problem 62: Cubic permutations
❱
2.62.1.
Brute force
2.62.2.
Iterating and caching
2.62.3.
Solution
2.63.
Problem 63: Powerful digit counts
❱
2.63.1.
Brute force
2.63.2.
Back to initial equation
2.63.3.
Solution
2.64.
Problem 64: Odd period square roots
❱
2.64.1.
Brute force
2.64.2.
Another property of continued fractions
2.64.3.
Solution
2.65.
Problem 65: Convergents of e
❱
2.65.1.
Brute force
2.65.2.
Solution
2.66.
Problem 66: Diophantine equation
❱
2.66.1.
Brute force
2.66.2.
Solving Pell's equations
2.66.3.
Solution
2.67.
Problem 67: Maximum path sum II
❱
2.67.1.
Brute force
2.67.2.
Solution
2.68.
Problem 68: Magic 5-gon ring
❱
2.68.1.
Brute force
2.68.2.
Solution
2.69.
Problem 69: Totient maximum
❱
2.69.1.
Brute force
2.69.2.
Caching totients
2.69.3.
Euler's totient function
2.69.4.
Solution
2.70.
Problem 70: Totient permutation
❱
2.70.1.
Brute force
2.70.2.
Euler's totient function
2.70.3.
Solution
2.71.
Problem 71: Ordered fractions
❱
2.71.1.
Brute force
2.71.2.
Farey sequence
2.71.3.
Solution
2.72.
Problem 72: Counting fractions
❱
2.72.1.
Brute force
2.72.2.
Farey sequence and Euler's totient function
2.72.3.
Solution
2.73.
Problem 73: Counting fractions in a range
❱
2.73.1.
Brute force
2.73.2.
Solution
2.74.
Problem 74: Digit factorial chains
❱
2.74.1.
Brute force
2.74.2.
Caching the chain
2.74.3.
Solution
2.75.
Problem 75: Singular Integer Right Triangles
❱
2.75.1.
Tree of primitive Pythagorean triples
2.75.2.
Solution
2.76.
Problem 76: Counting Summations
❱
2.76.1.
Dynamic programming
2.76.2.
Solution
2.77.
Problem 77: Prime Summations
❱
2.77.1.
Dynamic programming is hidden recursion problem
2.77.2.
Solution
2.78.
Problem 78: Coin Partitions
❱
2.78.1.
Dynamic programming
2.78.2.
Euler partition function
2.78.3.
Solution
2.79.
Problem 79: Passcode Derivation
❱
2.79.1.
Topological sorting
2.79.2.
Solution
2.80.
Problem 80: Square Root Digital Expansion
❱
2.80.1.
Square roots by subtraction
2.80.2.
Solution
2.81.
Problem 81: Path Sum: Two Ways
❱
2.81.1.
Dynamic programming
2.81.2.
Solution
2.82.
Problem 82: Path Sum: Three Ways
❱
2.82.1.
Dynamic programming
2.82.2.
Solution
2.83.
Problem 83: Path Sum: Four Ways
❱
2.83.1.
Breadth-first search
2.83.2.
Dijkstra's algorithm
2.83.3.
Solution
3.
Usage
4.
Contributing
Light
Rust
Coal
Navy
Ayu
Project Euler
Solution
4613732