Skip to content

Repository containing algorithmic solutions to Project Euler challenges. Each solution has been methodically developed, optimized, and rigorously tested. Engage in mathematical and computational problem-solving.

License

Notifications You must be signed in to change notification settings

AkarisDimitry/ProjectEuler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Euler Solutions

image

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:

Table of Contents

Table of Contents

  1. Multiples of 3 and 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
  76. Counting summations
  77. Prime summations
  78. Coin partitions
  79. Passcode derivation
  80. Square root digital expansion
  81. Path sum: two ways
  82. Path sum: three ways
  83. Path sum: four ways
  84. Monopoly odds
  85. Counting rectangles
  86. Cuboid route
  87. Prime power triples
  88. Product-sum numbers
  89. Roman numerals
  90. Cube digit pairs
  91. Right triangles with integer coordinates
  92. Square digit chains
  93. Arithmetic expressions
  94. Almost equilateral triangles
  95. Amicable chains
  96. Su Doku
  97. Large non-Mersenne prime
  98. Anagramic squares
  99. Largest exponential
  100. Arranged probability

Problem 1: Multiples of 3 and 5

Topic: Arithmetic
Description: Sum of multiples of 3 or 5 below 1000.

Problem 2: Even Fibonacci numbers

Topic: Sequences
Description: Sum of even Fibonacci numbers up to four million.

Problem 3: Largest prime factor

Topic: Number Theory
Description: Largest prime factor of the number 600851475143.

Problem 4: Largest palindrome product

Topic: Arithmetic
Description: Largest palindrome made from the product of two 3-digit numbers.

Problem 5: Smallest multiple

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.

Problem 6: Sum square difference

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.

Problem 7: 10,001st prime

Topic: Number Theory
Description: Finding the 10,001st prime number.
Explanation: Introduces prime number generation and the Sieve of Eratosthenes.

Problem 8: Largest product in a series

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.

Problem 9: Special Pythagorean triplet

Topic: Geometry
Description: Pythagorean triplet for which a + b + c = 1000.
Explanation: Relates to the Pythagorean theorem and integer solutions.

Problem 10: Summation of primes

Topic: Number Theory
Description: Sum of all primes below two million.
Explanation: Explores prime number generation and summation.

Problem 11: Largest product in a grid

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.

Problem 12: Highly divisible triangular number

Topic: Number Theory
Description: First triangle number to have over 500 divisors.
Explanation: Involves generating triangular numbers and factorization.

Problem 13: Large sum

Topic: Arithmetic
Description: Find the first ten digits of the sum of one hundred 50-digit numbers.
Explanation: Basic large number arithmetic.

Problem 14: Longest Collatz sequence

Topic: Sequences
Description: Starting number under one million that produces the longest Collatz sequence.
Explanation: Iterative sequence generation with caching or memoization.

Problem 15: Lattice paths

Topic: Combinatorics
Description: How many routes are there through a 20×20 grid without backtracking?
Explanation: Binomial coefficients and combinatorial path counting.

Problem 16: Power digit sum

Topic: Arithmetic
Description: Sum of the digits of the number (2^{1000}).
Explanation: Large number exponentiation and digit summation.

Problem 17: Number letter counts

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.

Problem 18: Maximum path sum I

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.

Problem 19: Counting Sundays

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.

Problem 20: Factorial digit sum

Topic: Arithmetic
Description: Find the sum of the digits in 100!.
Explanation: Involves computing large factorials and summing their digits.

Problem 21: Amicable numbers

Topic: Number Theory
Description: Evaluate the sum of all amicable numbers under 10000.
Explanation: Investigates number properties, particularly the sum of divisors.

Problem 22: Names scores

Topic: String Manipulation
Description: Calculate the total name score for a list of names.
Explanation: Involves sorting and character value computations for strings.

Problem 23: Non-abundant sums

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.

Problem 24: Lexicographic permutations

Topic: Permutations
Description: Find the millionth lexicographic permutation of the digits 0 through 9.
Explanation: Deals with generating and ordering permutations.

Problem 25: 1000-digit Fibonacci number

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.

Problem 26: Reciprocal cycles

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.

Problem 27: Quadratic primes

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.

Problem 28: Number spiral diagonals

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.

Problem 29: Distinct powers

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.

Problem 30: Digit fifth powers

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.

Problem 31: Coin sums

Topic: Combinatorics
Description: How many ways can £2 be made using any number of coins?
Explanation: Uses combinatorial mathematics to count coin combinations.

Problem 32: Pandigital products

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.

Problem 33: Digit cancelling fractions

Topic: Number Theory
Description: Discover all the fractions with an unorthodox cancelling method.
Explanation: Investigates properties of fractions and digit cancellation.

Problem 34: Digit factorials

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.

Problem 35: Circular primes

Topic: Number Theory
Description: How many circular primes are there below one million?
Explanation: Explores prime generation and properties of circular number rotations.

Problem 36: Double-base palindromes

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.

Problem 37: Truncatable primes

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.

Problem 38: Pandigital multiples

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.

Problem 39: Integer right triangles

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.

Problem 40: Champernowne's constant

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.

Problem 41: Pandigital prime

Topic: Number Theory
Description: What is the largest n-digit pandigital prime that exists?
Explanation: Combines prime number generation with pandigital checks.

Problem 42: Coded triangle numbers

Topic: Number Theory
Description: How many words from a list have a triangular word value?
Explanation: Investigates properties of triangular numbers.

Problem 43: Sub-string divisibility

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.

Problem 44: Pentagon numbers

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.

Problem 45: Triangular, pentagonal, and hexagonal

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.

Problem 46: Goldbach's other conjecture

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.

Problem 47: Distinct primes factors

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.

Problem 48: Self powers

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.

Problem 49: Prime permutations

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.

Problem 50: Consecutive prime sum

Topic: Number Theory
Description: Prime below one million that can be written as the sum of the most consecutive primes.

Problem 51: Prime digit replacements

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.

Problem 52: Permuted multiples

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.

Problem 53: Combinatoric selections

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.

Problem 54: Poker hands

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.

Problem 55: Lychrel numbers

Topic: Arithmetic
Description: How many Lychrel numbers are there below ten thousand?
Explanation: Explores the properties of number palindromes and iterative transformations.

Problem 56: Powerful digit sum

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.

Problem 57: Square root convergents

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.

Problem 58: Spiral primes

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.

Problem 59: XOR decryption

Topic: Cryptography
Description: Decrypt a message by discovering the three-character key.
Explanation: Engages with XOR operations and basic cryptographic techniques.

Problem 60: Prime pair sets

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.

Problem 61: Cyclical figurate numbers

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.

Problem 62: Cubic permutations

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.

Problem 63: Powerful digit counts

Topic: Arithmetic
Description: How many n-digit positive integers exist which are also an nth power?
Explanation: Explores relationships between number lengths and powers.

Problem 64: Odd period square roots

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.

Problem 65: Convergents of ( e )

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.

Problem 66: Diophantine equation

Topic: Number Theory
Description: Solve the Diophantine equation ( x^2 - Dy^2 = 1 ).
Explanation: Investigates Pell's equation and its solutions.

Problem 67: Maximum path sum II

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.

Problem 68: Magic 5-gon ring

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.

Problem 69: Totient maximum

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.

Problem 70: Totient permutation

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.

Problem 71: Ordered fractions

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.

Problem 72: Counting fractions

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.

Problem 73: Counting fractions in a range

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.

Problem 74: Digit factorial chains

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.

Problem 75: Singular integer right triangles

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.

Problem 76: Counting summations

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.

Problem 77: Prime summations

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.

Problem 78: Coin partitions

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.

Problem 79: Passcode derivation

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.

Problem 80: Square root digital expansion

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.

Problem 81: Path sum: two ways

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.

Problem 82: Path sum: three ways

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.

Problem 83: Path sum: four ways

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.

Problem 84: Monopoly odds

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.

Problem 85: Counting rectangles

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.

Problem 86: Cuboid route

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.

Problem 87: Prime power triples

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.

Problem 88: Product-sum numbers

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.

Problem 89: Roman numerals

Topic: String Manipulation
Description: Convert a set of Roman numerals to minimal form.
Explanation: Engages with properties and rules of Roman numeral representation.

Problem 90: Cube digit pairs

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.

Problem 91: Right triangles with integer coordinates

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.

Problem 92: Square digit chains

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.

Problem 93: Arithmetic expressions

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.

Problem 94: Almost equilateral triangles

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.

Problem 95: Amicable chains

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.

Problem 96: Su Doku

Topic: Logic, Backtracking
Description: Solve a series of Su Doku puzzles.
Explanation: Implements logic-based puzzle-solving techniques, often using backtracking algorithms.

Problem 97: Large non-Mersenne prime

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.

Problem 98: Anagramic squares

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.

Problem 99: Largest exponential

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.

Problem 100: Arranged probability

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.


Contributing

If you have suggestions or optimizations for any of the solutions, feel free to make a pull request or open an issue.

License

This project is licensed under the MIT License.