This repository contains algorithmic solutions to challenges from Project Euler. Each problem is tackled with a combination of mathematical insight and computational optimization. Below is a brief overview of the topics and themes for each problem:
- Multiples of 3 and 5
- Even Fibonacci numbers
- Largest prime factor
- Largest palindrome product
- Smallest multiple
- Sum square difference
- 10,001st prime
- Largest product in a series
- Special Pythagorean triplet
- Summation of primes
- Largest product in a grid
- Highly divisible triangular number
- Large sum
- Longest Collatz sequence
- Lattice paths
- Power digit sum
- Number letter counts
- Maximum path sum I
- Counting Sundays
- Factorial digit sum
- Amicable numbers
- Names scores
- Non-abundant sums
- Lexicographic permutations
- 1000-digit Fibonacci number
- Reciprocal cycles
- Quadratic primes
- Number spiral diagonals
- Distinct powers
- Digit fifth powers
- Coin sums
- Pandigital products
- Digit cancelling fractions
- Digit factorials
- Circular primes
- Double-base palindromes
- Truncatable primes
- Pandigital multiples
- Integer right triangles
- Champernowne's constant
- Pandigital prime
- Coded triangle numbers
- Sub-string divisibility
- Pentagon numbers
- Triangular, pentagonal, and hexagonal
- Goldbach's other conjecture
- Distinct primes factors
- Self powers
- Prime permutations
- Consecutive prime sum
- Prime digit replacements
- Permuted multiples
- Combinatoric selections
- Poker hands
- Lychrel numbers
- Powerful digit sum
- Square root convergents
- Spiral primes
- XOR decryption
- Prime pair sets
- Cyclical figurate numbers
- Cubic permutations
- Powerful digit counts
- Odd period square roots
- Convergents of e
- Diophantine equation
- Maximum path sum II
- Magic 5-gon ring
- Totient maximum
- Totient permutation
- Ordered fractions
- Counting fractions
- Counting fractions in a range
- Digit factorial chains
- Singular integer right triangles
- Counting summations
- Prime summations
- Coin partitions
- Passcode derivation
- Square root digital expansion
- Path sum: two ways
- Path sum: three ways
- Path sum: four ways
- Monopoly odds
- Counting rectangles
- Cuboid route
- Prime power triples
- Product-sum numbers
- Roman numerals
- Cube digit pairs
- Right triangles with integer coordinates
- Square digit chains
- Arithmetic expressions
- Almost equilateral triangles
- Amicable chains
- Su Doku
- Large non-Mersenne prime
- Anagramic squares
- Largest exponential
- Arranged probability
Topic: Arithmetic
Description: Sum of multiples of 3 or 5 below 1000.
Topic: Sequences
Description: Sum of even Fibonacci numbers up to four million.
Topic: Number Theory
Description: Largest prime factor of the number 600851475143.
Topic: Arithmetic
Description: Largest palindrome made from the product of two 3-digit numbers.
Topic: Arithmetic
Description: Smallest positive number that is evenly divisible by all numbers from 1 to 20.
Explanation: Delves into Least Common Multiples (LCM) and their properties.
Topic: Algebra
Description: Difference between the sum of the squares and the square of the sum for the first 100 natural numbers.
Explanation: Explores the algebraic expansion of polynomial expressions.
Topic: Number Theory
Description: Finding the 10,001st prime number.
Explanation: Introduces prime number generation and the Sieve of Eratosthenes.
Topic: Arithmetic
Description: Greatest product of thirteen adjacent digits in a given 1000-digit number.
Explanation: Involves scanning and multiplying subsets of a large number.
Topic: Geometry
Description: Pythagorean triplet for which a + b + c = 1000.
Explanation: Relates to the Pythagorean theorem and integer solutions.
Topic: Number Theory
Description: Sum of all primes below two million.
Explanation: Explores prime number generation and summation.
Topic: Arrays
Description: Greatest product of four adjacent numbers in any direction (up, down, left, right, or diagonally) in a 20×20 grid.
Explanation: Requires scanning through a matrix and performing local multiplications.
Topic: Number Theory
Description: First triangle number to have over 500 divisors.
Explanation: Involves generating triangular numbers and factorization.
Topic: Arithmetic
Description: Find the first ten digits of the sum of one hundred 50-digit numbers.
Explanation: Basic large number arithmetic.
Topic: Sequences
Description: Starting number under one million that produces the longest Collatz sequence.
Explanation: Iterative sequence generation with caching or memoization.
Topic: Combinatorics
Description: How many routes are there through a 20×20 grid without backtracking?
Explanation: Binomial coefficients and combinatorial path counting.
Topic: Arithmetic
Description: Sum of the digits of the number (2^{1000}).
Explanation: Large number exponentiation and digit summation.
Topic: String Manipulation
Description: If numbers 1 to 1000 were written out in words, how many letters would be used?
Explanation: Transforms numbers into their word representation and counts characters.
Topic: Dynamic Programming
Description: Find the maximum sum traveling from the top to the bottom of a triangle.
Explanation: Uses dynamic programming to optimize path sum calculations in a triangle structure.
Topic: Date and Time
Description: How many Sundays fell on the first of the month during the 20th century?
Explanation: Engages with calendar computations and weekday calculations.
Topic: Arithmetic
Description: Find the sum of the digits in 100!.
Explanation: Involves computing large factorials and summing their digits.
Topic: Number Theory
Description: Evaluate the sum of all amicable numbers under 10000.
Explanation: Investigates number properties, particularly the sum of divisors.
Topic: String Manipulation
Description: Calculate the total name score for a list of names.
Explanation: Involves sorting and character value computations for strings.
Topic: Number Theory
Description: Find the sum of all positive integers which cannot be written as the sum of two abundant numbers.
Explanation: Investigates abundant numbers and their properties.
Topic: Permutations
Description: Find the millionth lexicographic permutation of the digits 0 through 9.
Explanation: Deals with generating and ordering permutations.
Topic: Sequences
Description: Determine the index of the first term in the Fibonacci sequence to contain 1000 digits.
Explanation: Explores the properties and growth of the Fibonacci sequence.
Topic: Number Theory
Description: Find the value of ( d ) < 1000 for which ( \frac{1}{d} ) contains the longest recurring cycle.
Explanation: Involves understanding recurring cycles in decimal fractions.
Topic: Number Theory
Description: Find the product of the coefficients, ( a ) and ( b ), for the quadratic expression that produces the maximum number of primes for consecutive values of ( n ).
Explanation: Examines prime generation using quadratic formulas.
Topic: Patterns and Sequences
Description: Find the sum of the numbers on the diagonals in a 1001 by 1001 spiral.
Explanation: Investigates patterns in a spirally arranged number grid.
Topic: Arithmetic
Description: How many distinct terms are in the sequence generated by ( a^b ) for ( 2 \leq a \leq 100 ) and ( 2 \leq b \leq 100 )?
Explanation: Involves large number exponentiation and uniqueness checks.
Topic: Arithmetic
Description: Find the sum of all numbers that can be written as the sum of fifth powers of their digits.
Explanation: Explores properties of numbers and their digit powers.
Topic: Combinatorics
Description: How many ways can £2 be made using any number of coins?
Explanation: Uses combinatorial mathematics to count coin combinations.
Topic: Number Theory
Description: Find the sum of all products whose multiplicand/multiplier/product identity can be written as a 1 through 9 pandigital.
Explanation: Deals with number properties and pandigital checks.
Topic: Number Theory
Description: Discover all the fractions with an unorthodox cancelling method.
Explanation: Investigates properties of fractions and digit cancellation.
Topic: Arithmetic
Description: Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Explanation: Involves computing factorial values for digits and checking sums.
Topic: Number Theory
Description: How many circular primes are there below one million?
Explanation: Explores prime generation and properties of circular number rotations.
Topic: Number Theory
Description: Find the sum of all numbers less than one million, which are palindromic in base 10 and base 2.
Explanation: Examines palindromic properties in different bases.
Topic: Number Theory
Description: Find the sum of the only eleven primes that are both truncatable from left to right and right to left.
Explanation: Investigates prime properties and truncation checks.
Topic: Number Theory
Description: Find the largest 1 to 9 pandigital that can be formed by multiplying a fixed number by 1, 2, 3, ...
Explanation: Explores properties of numbers and pandigital checks.
Topic: Geometry
Description: For which value of ( p ) under 1000, is the number of solutions maximized for a right triangle with integral side lengths?
Explanation: Relates to the Pythagorean theorem and integer solutions.
Topic: Sequences
Description: Finding the nth digit of the fractional part of the irrational number formed by concatenating positive integers.
Explanation: Investigates properties of sequences and positional values.
Topic: Number Theory
Description: What is the largest n-digit pandigital prime that exists?
Explanation: Combines prime number generation with pandigital checks.
Topic: Number Theory
Description: How many words from a list have a triangular word value?
Explanation: Investigates properties of triangular numbers.
Topic: Number Theory
Description: Find the sum of all 0 to 9 pandigital numbers with a sub-string divisibility property.
Explanation: Examines number properties and specific divisibility checks.
Topic: Number Theory
Description: Find the pair of pentagonal numbers for which their sum and difference are pentagonal and the difference is minimized.
Explanation: Investigates properties of pentagonal numbers.
Topic: Number Theory
Description: Find the next triangle number that is also pentagonal and hexagonal beyond 40755.
Explanation: Examines properties and generation of polygonal numbers.
Topic: Number Theory
Description: Find the smallest odd composite that cannot be written as the sum of a prime and twice a square.
Explanation: Investigates properties of numbers in relation to Goldbach's conjecture.
Topic: Number Theory
Description: Find the first four consecutive integers to have four distinct prime factors each.
Explanation: Involves prime factorization and consecutive number checks.
Topic: Arithmetic
Description: Find the last ten digits of the series ( 1^1 + 2^2 + ... + 1000^{1000} ).
Explanation: Engages with large number exponentiation and modular arithmetic.
Topic: Number Theory, Permutations
Description: Three terms in an arithmetic sequence, all prime, and all permutations of each other.
Explanation: Combines prime number generation with combinatorial string manipulation.
Topic: Number Theory
Description: Prime below one million that can be written as the sum of the most consecutive primes.
Topic: Number Theory
Description: Find the smallest prime which, by replacing part of the number (not necessarily adjacent digits) with the same digit, is part of an eight prime value family.
Explanation: Combination of prime generation and string manipulation to identify prime families.
Topic: Number Theory, Permutations
Description: Find the smallest positive integer, ( x ), such that ( 2x, 3x, 4x, 5x, ) and ( 6x ) contain the same digits.
Explanation: Analyzes number properties and their digit permutations.
Topic: Combinatorics
Description: How many values of ( C(n, r) ) for ( 1 \leq n \leq 100 ) are greater than one million?
Explanation: Uses binomial coefficients and combinatorial mathematics.
Topic: Game Theory, Probability
Description: How many poker hands does Player 1 win out of 1000 games?
Explanation: Application of poker rules and ranking mechanisms.
Topic: Arithmetic
Description: How many Lychrel numbers are there below ten thousand?
Explanation: Explores the properties of number palindromes and iterative transformations.
Topic: Arithmetic
Description: Considering natural numbers of the form, ( a^b ), where ( a, b < 100 ), what is the maximum digital sum?
Explanation: Explores large number exponentiation and digit summation.
Topic: Number Theory, Fractions
Description: In the first one-thousand expansions of the fraction for the square root of 2, how many fractions contain a numerator with more digits than the denominator?
Explanation: Examines continued fraction expansions and their properties.
Topic: Number Theory
Description: What is the side length of the square spiral for which the ratio of primes along both diagonals first falls below 10%?
Explanation: Investigates prime densities in spirally arranged grids.
Topic: Cryptography
Description: Decrypt a message by discovering the three-character key.
Explanation: Engages with XOR operations and basic cryptographic techniques.
Topic: Number Theory
Description: Find the lowest sum for a set of five primes for which any two primes concatenate to produce another prime.
Explanation: Investigates prime properties and concatenation behaviors.
Topic: Number Theory
Description: Find the sum of the only set of six cyclic 4-digit numbers representing different polygonal types.
Explanation: Examines properties of polygonal numbers.
Topic: Number Theory
Description: Find the smallest cube for which exactly five permutations of its digits are cube.
Explanation: Investigates properties of cubed numbers and their digit permutations.
Topic: Arithmetic
Description: How many n-digit positive integers exist which are also an nth power?
Explanation: Explores relationships between number lengths and powers.
Topic: Number Theory
Description: How many continued fractions for ( \sqrt{N} ) have an odd period?
Explanation: Investigates the properties of continued fraction expansions for square roots.
Topic: Number Theory
Description: Find the sum of digits in the numerator of the 100th convergent of the continued fraction for ( e ).
Explanation: Explores the properties of continued fractions and their convergents.
Topic: Number Theory
Description: Solve the Diophantine equation ( x^2 - Dy^2 = 1 ).
Explanation: Investigates Pell's equation and its solutions.
Topic: Dynamic Programming
Description: Find the maximum sum traveling from the top to the bottom of a triangle (similar to Problem 18, but with a larger triangle).
Explanation: Uses dynamic programming to optimize path sum calculations in a triangle structure.
Topic: Combinatorics
Description: Arrange numbers in a 5-gon ring such that the total of each set of three numbers is the same.
Explanation: Investigates combinatorial properties of number rings.
Topic: Number Theory
Description: Find the value of ( n ) ≤ 1,000,000 for which ( n/\phi(n) ) is a maximum.
Explanation: Involves Euler's Totient function and its properties.
Topic: Number Theory
Description: Find the value of ( n ) for which ( \phi(n) ) is a permutation of ( n ) and the ratio ( n/\phi(n) ) produces a minimum.
Explanation: Further exploration of Euler's Totient function and number permutations.
Topic: Number Theory
Description: Determine the numerator of the fraction immediately to the left of 3/7 in a sorted set of reduced proper fractions.
Explanation: Engages with properties of fractions and their orderings.
Topic: Number Theory
Description: How many elements would be contained in the set of reduced proper fractions for ( d \leq 1,000,000 )?
Explanation: Involves understanding reduced fractions and the Euler's Totient function.
Topic: Number Theory
Description: How many fractions lie between 1/3 and 1/2 in the sorted set of reduced proper fractions for ( d \leq 12,000 )?
Explanation: Explores properties of fractions in a specific range.
Topic: Arithmetic
Description: How many factorial chains, with a starting number below one million, contain exactly sixty non-repeating terms?
Explanation: Investigates chains formed by summing factorials of digits.
Topic: Geometry, Number Theory
Description: For how many values of ( L ) less than 1,500,000 can exactly one integer sided right triangle be formed?
Explanation: Explores properties of Pythagorean triplets.
Topic: Combinatorics
Description: How many different ways can 100 be written as a sum of at least two positive integers?
Explanation: Engages with partitioning numbers in combinatorial ways.
Topic: Number Theory
Description: What is the first value which can be written as the sum of primes in over five thousand different ways?
Explanation: Combines prime generation with number partitioning.
Topic: Combinatorics
Description: Let ( p(n) ) represent the number of different ways in which ( n ) coins can be separated into piles. Find the least value of ( n ) for which ( p(n) ) is divisible by one million.
Explanation: Investigates partition functions and modular arithmetic.
Topic: Logic, String Manipulation
Description: Analyze a series of failed login attempts to deduce the original passcode.
Explanation: Uses logic to order digits based on their appearance in failed attempts.
Topic: Arithmetic
Description: For the first 100 natural numbers, find the total of the digital sums of the first 100 decimal digits for all the irrational square roots.
Explanation: Engages with high precision arithmetic.
Topic: Dynamic Programming
Description: Find the minimal path sum from the top left to the bottom right by moving right and down in a matrix.
Explanation: Uses dynamic programming to find the shortest path in a grid.
Topic: Dynamic Programming
Description: Find the minimal path sum from the left column to the right column in a matrix, only moving up, down, and right.
Explanation: Further explores grid path optimizations.
Topic: Dynamic Programming
Description: Find the minimal path sum from the top left to the bottom right by moving left, right, up, and down in a matrix.
Explanation: Explores grid paths with added movement freedom.
Topic: Probability, Simulation
Description: In the game of Monopoly, determine the three most popular squares to land on.
Explanation: Uses simulation and probability to model game movements.
Topic: Combinatorics
Description: By counting rectangles in different sized grids, determine the area of the grid with the nearest solution to containing 2 million rectangles.
Explanation: Engages with combinatorial rectangle counting.
Topic: Geometry
Description: Investigate the shortest path between two corners of a cuboid when moving on its surfaces.
Explanation: Relates to geometric properties of cuboids.
Topic: Number Theory
Description: How many numbers below fifty million can be expressed as the sum of a prime square, prime cube, and prime fourth power?
Explanation: Combines prime number generation with specific power calculations.
Topic: Number Theory
Description: For 2 ≤ ( k ) ≤ 12000, find the sum of the minimal product-sum numbers.
Explanation: Investigates numbers which can be both a product and a sum.
Topic: String Manipulation
Description: Convert a set of Roman numerals to minimal form.
Explanation: Engages with properties and rules of Roman numeral representation.
Topic: Combinatorics
Description: By selecting two sets of six digits from 0 to 9, determine how many combinations can represent all the square numbers below one hundred.
Explanation: Explores combinatorial properties of digit selections.
Topic: Geometry
Description: Determine the number of right angle triangles with integer coordinates in the grid from (0,0) to (50,50).
Explanation: Relates to geometric properties of triangles on a coordinate grid.
Topic: Number Theory
Description: Determine how many starting numbers below ten million will arrive at 89 after iterating a process of squaring its digits.
Explanation: Investigates chains formed by summing squares of digits.
Topic: Combinatorics, Arithmetic
Description: By using any of the four arithmetic operations, determine the longest set of target numbers that can be achieved using four distinct digits.
Explanation: Engages with combinatorial properties of arithmetic operations.
Topic: Geometry
Description: Find the sum of the perimeters of all almost equilateral triangles with integral side lengths and area that have perimeters below one billion.
Explanation: Explores geometric properties of triangles with near-equal sides.
Topic: Number Theory
Description: Find the smallest member of the longest amicable chain with no element exceeding one million.
Explanation: Explores amicable numbers and their chains.
Topic: Logic, Backtracking
Description: Solve a series of Su Doku puzzles.
Explanation: Implements logic-based puzzle-solving techniques, often using backtracking algorithms.
Topic: Number Theory
Description: Find the last ten digits of the non-Mersenne prime: ( 28433 \times 2^{7830457} + 1 ).
Explanation: Engages with modular arithmetic to handle large numbers.
Topic: Number Theory, String Manipulation
Description: Find the largest square number formed by any member of an anagram pair.
Explanation: Combines number theory with combinatorial string manipulation to identify anagrammatic square numbers.
Topic: Number Theory
Description: Determine which line number has the greatest numerical value for base^exponent format.
Explanation: Explores properties of logarithms to compare exponential numbers efficiently.
Topic: Probability
Description: Finding the number of blue discs for which the probability of taking two blue discs is 0.5.
Explanation: Engages with probability in a combinatorial setting, focusing on ratios and large numbers.
If you have suggestions or optimizations for any of the solutions, feel free to make a pull request or open an issue.
This project is licensed under the MIT License.