|
The Euler Project provides a set of exercises, especially suited for novices in programming languages. Should you wish to take part in the competition, register at their website; and if you don't mind the spoiler, have a look at the solutions in Haskell. On this page I accumulate the algorithms written in OCaml. Contributions and questions are welcome at ocaml(at)christiankissig.de .
Note The authors of the euler project seem to suspect that some members use solution lists to increase their grades. I have therefore decided to discontinue publishing of plain solutions for now. If you get stuck with any problem in the list, which I indicate to have solved, feel free to ask me.
- Add all the natural numbers below one thousand multiples of that are 3 or 5.
[Solution, OCaml]
- Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.
[Solution, OCaml]
- Find the largest prime factor of a composite number.
[Solution, OCaml]
- Find the largest palindrome made from the product of two 3-digit numbers.
[Solution, OCaml]
- What is the smallest number divisible by each of the numbers 1 to 20?
[Solution, OCaml]
- What is the difference between the sum of the squares and the square of the sums?
[Solution, OCaml]
- Find the 10001st prime.
[Solution, OCaml]
- Discover the largest product of five consecutive digits in the 1000-digit number.
[Solution, OCaml]
- Find the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000.
[Solution, OCaml]
-
Calculate the sum of all the primes below two million.[ Solution, OCaml]
- What is the greatest product of four numbers on the same straight line in the 20 by 20 grid?
[Solution, OCaml]
- What is the value of the first triangle number to have over five hundred divisors.
[solved]
- Find the first ten digits of the sum of one-hundred 50-digit numbers.
[Solution, OCaml]
- Find the longest sequence using a starting number under one million.
[solved]
- Starting in the top left corner in a 20 by 20 grid, how many routes are there to the bottom right corner?
[solved]
- What is the sum of the digits of the number 21000?
[Solution, OCaml]
- How many letters would be needed to write all the numbers in words from 1 to 1000?
[solved]
- Find the maximum sum travelling from the top of the triangle to the base.
[solved]
- How many Sundays fell on the first of the month during the twentieth century?
[Solution, OCaml]
- Find the sum of digits in 100!
[Solution, OCaml]
- Evaluate the sum of all amicable pairs under 10000.
[Solution, OCaml]
- What is the total of all the name scores in the file of first names?
- Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers.
[Solution, OCaml]
- What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?
[solved]
- What is the first term in the Fibonacci sequence to contain 1000 digits?
[Solution, OCaml]
- Find the value of d < 1000 for which 1/d contains the longest recurring cycle.
[solved]
- Find a quadratic formula that produces the maximum number of primes for consecutive values of n.
[solved]
- What is the sum of both diagonals in a 1001 by 1001 spiral?
- How many distinct terms are in the sequence generated by ab for 2 ≤ a ≤ 100 and 2 ≤ b ≤ 100?
[solved]
- Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.
[solved]
- Investigating combinations of English currency denominations.
[Solution, OCaml]
- Find the sum of all numbers that can be written as pandigital products.
- Discover all the fractions with an unorthodox cancelling method.
- Find the sum of all numbers which are equal to the sum of the factorial of their digits.
- How many circular primes are there below one million?
[solved]
- Find the sum of all numbers less than one million, which are palindromic in base 10 and base 2.
[Solution, OCaml]
- Find the sum of all eleven primes that are both truncatable from left to right and right to left.
[Solution, OCaml]
- What is the largest 1 to 9 pandigital that can be formed by multiplying a fixed number by 1, 2, 3, ...?
- If p is the perimeter of a right angle triangle, {a, b, c}, which value, for p ≤ 1000, has the most solutions?
- Finding the nth digit of the fractional part of the irrational number.
- What is the largest n-digit pandigital prime that exists?
- How many triangle words does the list of common English words contain?
- Find the sum of all pandigital numbers with an unusual sub-string divisibility property.
- Find the smallest pair of pentagonal numbers whose sum and difference is pentagonal.
- After 40755, what is the next triangle number that is also pentagonal and hexagonal?
[solved]
- What is the smallest odd composite that cannot be written as the sum of a prime and twice a square?
[Solution, OCaml]
- Find the first four consecutive integers to have four distinct primes factors.
- Find the last ten digits of 11 + 22 + ... + 10001000.
- Find arithmetic sequences, made of prime terms, whose four digits are permutations of each other.
[Solution, OCaml]
- Which prime, below one-million, can be written as the sum of the most consecutive primes?
- Find the smallest prime which, by changing the same part of the number, can form eight different primes.
- Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits in some order.
[Solution, OCaml]
- How many values of C(n,r), for 1 ≤ n ≤ 100, exceed one-million?
[Solution, OCaml]
- How many hands did player one win in the game of poker?
- How many Lychrel numbers are there below ten-thousand?
[solved]
- Considering natural numbers of the form, ab, finding the maximum digital sum.
[solved]
- Investigate the expansion of the continued fraction for the square root of two.
- Investigate the number of primes that lie on the diagonals of the spiral grid.
- Using a brute force attack, can you decrypt the cipher using XOR encryption?
- Find a set of five primes for which any two primes concatenate to produce another prime.
- Find the sum of the only set of six 4-digit figurate numbers with a cyclic property.
- Find the smallest cube for which exactly five permutations of its digits are cube.
- How many n-digit positive integers exist which are also an nth power?
[Solution, OCaml]
- How many continued fractions for N ≤ 10000 have an odd period?
- Find the sum of digits in the numerator of the 100th convergent of the continued fraction for e.
- Investigate the Diophantine equation x2 − Dy2 = 1.
- Using an efficient algorithm find the maximal sum in the triangle?
- What is the maximum 16-digit string for a "magic" 5-gon ring?
- Find the value of n ≤ 1,000,000 for which n/φ(n) is a maximum.
- Investigate values of n for which φ(n) is a permutation of n.
- Listing reduced proper fractions in ascending order of size.
- How many elements would be contained in the set of reduced proper fractions for d ≤ 1,000,000?
- How many fractions lie between 1/3 and 1/2 in a sorted set of reduced proper fractions?
[Solution, OCaml]
- Determine the number of factorial chains that contain exactly sixty non-repeating terms.
[Solution, OCaml]
- Find the number of different lengths of wire can that can form a right angle triangle in only one way.
- How many different ways can one hundred be written as a sum of at least two positive integers?
- What is the first value which can be written as the sum of primes in over five thousand different ways?
- Investigating the number of ways in which coins can be separated into piles.
- By analysing a user's login attempts, can you determine the secret numeric passcode?
- Calculating the digital sum of the decimal digits of irrational square roots.
- Find the minimal path sum from the top left to the bottom right by moving right and down.
- Find the minimal path sum from the left column to the right column.
- Find the minimal path sum from the top left to the bottom right by moving left, right, up, and down.
- In the game, Monopoly, find the three most popular squares when using two 4-sided dice.
- Investigating the number of rectangles in a rectangular grid.
- Exploring the shortest path from one corner of a cuboid to another.
- Investigating numbers that can be expressed as the sum of a prime square, cube, and fourth power?
- Exploring minimal product-sum numbers for sets of different sizes.
- Develop a method to express Roman numerals in minimal form.
- An unexpected way of using two cubes to make a square.
- Find the number of right angle triangles in the quadrant.
- Investigating a square digits number chain with a surprising property.
- Using four distinct digits and the rules of arithmetic, find the longest sequence of target numbers.
- Investigating almost equilateral triangles with integral sides and area.
- Find the smallest member of the longest amicable chain with no element exceeding one million.
- Devise an algorithm for solving Su Doku puzzles.
- Find the last ten digits of the non-Mersenne prime: 28433 × 27830457 + 1.
- Investigating words, and their anagrams, which can represent square numbers.
- Which base/exponent pair in the file has the greatest numerical value?
- Finding the number of blue discs for which there is 50% chance of taking two blue.
- Investigate the optimum polynomial function to model the first k terms of a given sequence.
- For how many triangles in the text file does the interior contain the origin?
- Investigating sets with a special subset sum property.
- Finding Fibonacci numbers for which the first and last nine digits are pandigital.
- Find the sum of the special sum sets in the file.
- Find the minimum number of comparisons needed to identify special sum sets.
- Determining the most efficient way to connect the network.
- Solving the Diophantine equation 1/x + 1/y = 1/n.
- How many distinct ways can a player checkout in the game of darts with a score of less than 100?
- Find an efficient algorithm to analyse the number of solutions of the equation 1/x + 1/y = 1/n.
- Search for 10-digit primes containing the maximum number of repeated digits.
- Investigating the density of "bouncy" numbers.
- How many numbers below a googol (10100) are not "bouncy"?
- Investigating the number of ways to fill a row with separated blocks that are at least three units long.
- Finding a generalisation for the number of ways to fill a row with separated blocks.
- Investigating the number of ways of replacing square tiles with one of three coloured tiles.
- Investigating the number of ways of tiling a row using different-sized tiles.
- Exploring the number of ways in which sets containing prime elements can be made.
- Investigating the numbers which are equal to sum of their digits raised to some power.
- Finding the maximum remainder when (a − 1)n + (a + 1)n is divided by a2.
- Investigate the game of chance involving coloured discs.
- Finding the most efficient exponentiation method.
- Determining the remainder when (pn − 1)n + (pn + 1)n is divided by pn2.
- Determining the kth element of the sorted radical function.
- Finding square sums that are palindromic.
- Exploring the number of cubes required to cover every visible face on a cuboid.
- Investigating the number of abc-hits below a given limit.
- Which tiles in the hexagonal arrangement have prime differences with neighbours?
- Investigating minimal repunits that divide by n.
- Finding composite values, n, for which n−1 is divisible by the length of the smallest repunits that divide it.
- Determining primes, p, for which n3 + n2p is a perfect cube.
- Determining the first forty prime factors of a very large repunit.
- Investigating which primes will never divide a repunit containing 10n digits.
- Finding the smallest positive integer related to any pair of consecutive primes.
- Determining the number of solutions of the equation x2 − y2 − z2 = n.
- Discover when the equation x2 − y2 − z2 = n has a unique solution.
- Determining the value of infinite polynomial series for which the coefficients are Fibonacci numbers.
- Investigating isosceles triangle for which the height and base length differ by one.
- Finding Pythagorean triangles which allow the square on the hypotenuse square to be tiled.
- Investigating the value of infinite polynomial series for which the coefficients are a linear second order recurrence relation.
- Investigating progressive numbers, n, which are also square.
- Perfect Square Collection
- Investigating the Torricelli point of a triangle
- Investigating multiple reflections of a laser beam.
- How many reversible numbers are there below one-billion?
- Investigating a Prime Pattern
- Rectangles in cross-hatched grids
- Exploring Pascal's triangle.
- Searching for a maximum-sum subsequence.
- Searching a triangular array for a sub-triangle having minimum-sum.
- Paper sheets of standard sizes: an expected-value problem.
- Writing 1/2 as a sum of inverse squares
- Investigating Gaussian Integers
- Exploring Pascal's pyramid.
- Counting Capacitor Circuits.
- Counting Digits
- Solving the diophantine equation 1/a+1/b= p/10n
- Exploring strings for which only one character comes lexicographically after its neighbour to the left.
- Digital root sums of factorisations.
- Factorial trailing digits
- Triominoes
- Hexadecimal numbers
- Cross-hatched triangles
- Numbers for which no three consecutive digits have a sum greater than a given value.
- Intersections
- Criss Cross
- Investigating Ulam sequences
- Number Rotations
- Exploring the number of different ways a number can be expressed as a sum of powers of 2.
- Find the largest 0 to 9 pandigital that can be formed by concatenating products.
- Finding numbers for which the sum of the squares of the digits is a square.
- Investigating numbers with few repeated digits.
- Using up to one million tiles how many different "hollow" square laminae can be formed?
- Counting the number of "hollow" square laminae that can form one, two, three, ... distinct arrangements.
- Fractions involving the number of different ways a number can be expressed as a sum of powers of 2.
- Rectangular triangles that share a cathetus.
- Integer angled Quadrilaterals.
- Step Numbers
- Consecutive positive divisors
- Rational zeros of a function of three variables.
- Investigating in how many ways objects of two different colours can be grouped.
- RSA encryption
- Maximum product of parts
- Triangles containing the origin.
- Number Mind
- Connectedness of a network.
- Semiprimes
- The hyperexponentiation of a number
- Tri-colouring a triangular grid
- Maximising a weighted product
- Prize Strings
- Best Approximations
- Squarefree Numbers
- Coloured Configurations
- Inscribed circles of triangles with one angle of 60 degrees
- Prime triplets
- Investigating the behaviour of a recursively defined sequence
- Ambiguous Numbers
- Iterative Circle Packing
- Find the 200th prime-proof sqube containing the contiguous sub-string "200"
- Subsets with a unique sum
- Laserbeam
- Squarefree Binomial Coefficients
- Generalised Hamming Numbers
- Dice Game
- Concealed Square
- Integer partition equations
- Robot Walks
- Circular Logic
- Obtuse Angled Triangles
- Divisor Square Sum
- Combined Volume of Cuboids
- Flea Circus
- Totient Chains
- Crack-free Walls
- Investigating the primality of numbers of the form 2n2-1
- Balanced Numbers
- Perfect right-angled triangles
- Skew-cost coding
- Heighway Dragon
- Alexandrian Integers
- Sphere Packing
- Almost right-angled triangles I
- Almost right-angled triangles II
- Tribonacci non-divisors
- A Scoop of Blancmange
- The Chase
- Minkowski Sums
- Four Representations using Squares
- Fibonacci Words
- The prime factorisation of binomial coefficients
- The Race
- Lattice points on a circle
- Semidivisible numbers
- An Arithmetic Geometric sequence
- Luxury Hampers
- Tours on a 4 x n playing board
- Infinite string tour
- Twenty-two Foolish Primes
- Top Dice
- Perfection Quotients
- Odd Triplets
- Resilience
- Sliders
- Coresilience
- Tangents to an ellipse
- Squares under a hyperbola
- Numbers for which Euler’s totient function equals 13!
- Prime Subset Sums
- 250250
- Cardano Triplets
- Convex Holes
|