Skip to content

jlengrand/project_euler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My solutions to Project Euler 's website

Project Euler is a website containing lots of problems aiming at being solved.

This is always challenging to solve problems on paper, and fantastic to come up with an algorithmic solution. I use Python for its simplicity. Simple Python code is very similar to paper solution, and fast to implement.

Each script runs by itself and will directly pop the solution out.

The scripts are named as e_problemnumber_inc. The higher the inc, the finer the solution.

Here is a list of all already solved problems, with a one line explanation. Should be used in order to help future reuse of code :)

Note : I try to get my solutions within a one minute timeframe. What I want here is to solve problems, not get them running as fast as possible. So you may find some of the code here quite ugly. And this is the case :). Why optimize something that completely fits its purpose ? ;)

Problems solved

1 - Add all the natural numbers below one thousand that are multiples of 3 or 5. - 0.011
2 - By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. - 0.011
3 - Find the largest prime factor of a composite number. - < 1 sec
4 - Find the largest palindrome made from the product of two 3-digit numbers. - 0.790
5 - What is the smallest number divisible by each of the numbers 1 to 20? - 4.102
6 - What is the difference between the sum of the squares and the square of the sums? - 0.013
7 - Find the 10001st prime. - too long
8 - Discover the largest product of five consecutive digits in the 1000-digit number. - 0.045
9 - Find the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000. (a^2 + b^2 = c^2) - 1.500
10 - Calculate the sum of all the primes below two million. - too long
11 - What is the greatest product of four adjacent numbers on the same straight line in the 20 by 20 grid? - 0.048
12 - What is the value of the first triangle number to have over five hundred divisors? - too long
13 - Find the first ten digits of the sum of one-hundred 50-digit numbers. - 0.012
14 - Find the longest sequence using a starting number under one million. - too long
15 - Starting in the top left corner in a 20 by 20 grid, how many routes are there to the bottom right corner? - 0.012
16 - What is the sum of the digits of the number 2^1000? - 0.012
17 - How many letters would be needed to write all the numbers in words from 1 to 1000? - 0.012
18 - Find the maximum sum travelling from the top of the triangle to the base. - 0.012
19 - How many Sundays fell on the first of the month during the twentieth century? - 0.088
20 - Find the sum of digits in 100! - 0.031
21 - Evaluate the sum of all amicable pairs under 10000. (d(a) = b, d(b) = a) - 9.100
22 - What is the total of all the name scores in the file of first names? - 0.082
23 - Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers. - too long
24 - What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9? - too long
25 - What is the first term in the Fibonacci sequence to contain 1000 digits? - 0.741
26 - Find the value of d < 1000 for which 1/d contains the longest recurring cycle. < 5 sec
27 - Find a quadratic formula that produces the maximum number of primes for consecutive values of n. - too long
28 - What is the sum of both diagonals in a 1001 by 1001 spiral? - < 1 sec
29 - How many distinct terms are in the sequence generated by ab for 2 a 100 and 2 b 100? - < 1 sec
30 - Find the sum of all the numbers that can be written as the sum of fifth powers of their digits. - < 3 sec
31 - Investigating combinations of English currency denominations. - < 1 sec
33 - Discover all the fractions with an unorthodox cancelling method. < 1 sec
34 - Find the sum of all numbers which are equal to the sum of the factorial of their digits. - 30 sec - 16 sec
35 - How many circular primes are there below one million? - too long
36 - Find the sum of all numbers less than one million, which are palindromic in base 10 and base 2. - 0.933
37 - Find the sum of all eleven primes that are both truncatable from left to right and right to left. < 1 min
38 - What is the largest 1 to 9 pandigital that can be formed by multiplying a fixed number by 1, 2, 3, ... ? < 1 sec
39 - If p is the perimeter of a right angle triangle, {a, b, c}, which value, for p <= 1000, has the most solutions? - 1min
40 - Finding the nth digit of the fractional part of the irrational number. > 2 sec
41 - What is the largest n-digit pandigital prime that exists? < 5 min
42 - Using words.txt, a 16K text file containing nearly two-thousand common English words, how many are triangle words? - < 1 sec
43 - Find the sum of all pandigital numbers with an unusual sub-string +divisibility property. - 28sec
44 - Find the smallest pair of pentagonal numbers whose sum and difference is pentagonal. ~= 19 min
45 - Find the next triangle number that is also pentagonal and hexagonal. - < 1 sec
46 - What is the smallest odd composite that cannot be written as the sum of a prime and twice a square? - < 6 sec
48 - Find the last ten digits of 1^1 + 2^2 + ... + 1000^1000. - 0.053
49 - Prime permutations - 14.8
50 - Which prime, below one-million, can be written as the sum of the most consecutive primes? - ~= 1 hour
52 - Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits. - 2min
53 - How many values of C(n,r), for 1 <= n <= 100, exceed one-million? - < 1 sec
54 - How many hands does Player 1 win in radndom hands of Poker? - < 1 sec
55 - How many Lychrel numbers are there below ten-thousand? - < 1 sec
56 - Considering natural numbers of the form, a^b, finding the maximum digital sum. > 3 sec
59 - Decrypt XOR ASCII - 23.4s
67 - Using an efficient algorithm find the maximal sum in the triangle? - 0.027

In progress:

47 - Find the first four consecutive integers to have four distinct primes factors.
57 - How many fractions contain a numerator with more digits than denominator?
58 - What is the side length of the square spiral for which the ratio of primes along both diagonals first falls below 10%?
97 - Find the last ten digits of the non-Mersenne prime: 28433 � 2^7830457 + 1.

Contact

I would enjoy having feedback if you try to solve euler's problems too :). Feel free to mail me for any comment or request.

You can contact me at julien at lengrand dot fr, or on my current website

Current Project Euler status

Last update : 25/05/2014

About

Scripts and functions solving problems of Project Euler

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published