Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions project_euler/problems/025_1000_digit_fibonacci_number.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ http://projecteuler.net/problem=025
The Fibonacci sequence is defined by the recurrence relation:
Fn = Fn1 + Fn2, where F1 = 1 and F2 = 1.
Hence the first 12 terms will be:
F1 = 1
F2 = 1
F3 = 2
F4 = 3
F5 = 5
F6 = 8
F7 = 13
F8 = 21
F9 = 34
F10 = 55
F11 = 89
F1 = 1
F2 = 1
F3 = 2
F4 = 3
F5 = 5
F6 = 8
F7 = 13
F8 = 21
F9 = 34
F10 = 55
F11 = 89
F12 = 144
The 12th term, F12, is the first term to contain three digits.
What is the first term in the Fibonacci sequence to contain 1000 digits?
Expand Down
6 changes: 3 additions & 3 deletions project_euler/problems/057_square_root_convergents.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Square root convergents
It is possible to show that the square root of two can be expressed as an infinite continued fraction.
2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213...
By expanding this for the first four iterations, we get:
1 + 1/2 = 3/2 = 1.5
1 + 1/(2 + 1/2) = 7/5 = 1.4
1 + 1/(2 + 1/(2 + 1/2)) = 17/12 = 1.41666...
1 + 1/2 = 3/2 = 1.5
1 + 1/(2 + 1/2) = 7/5 = 1.4
1 + 1/(2 + 1/(2 + 1/2)) = 17/12 = 1.41666...
1 + 1/(2 + 1/(2 + 1/(2 + 1/2))) = 41/29 = 1.41379...
The next three expansions are 99/70, 239/169, and 577/408, but the eighth expansion, 1393/985, is the first example where the number of digits in the numerator exceeds the number of digits in the denominator.
In the first one-thousand expansions, how many fractions contain a numerator with more digits than denominator?
Expand Down
6 changes: 3 additions & 3 deletions project_euler/problems/066_diophantine_equation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ x2 – Dy2 = 1
For example, when D=13, the minimal solution in x is 6492 – 131802 = 1.
It can be assumed that there are no solutions in positive integers when D is square.
By finding minimal solutions in x for D = {2, 3, 5, 6, 7}, we obtain the following:
32 – 222 = 1
32 – 222 = 1
22 – 312 = 1
92 – 542 = 1
52 – 622 = 1
92 – 542 = 1
52 – 622 = 1
82 – 732 = 1
Hence, by considering minimal solutions in x for D 7, the largest x is obtained when D=5.
Find the value of D 1000 in minimal solutions of x for which the largest value of x is obtained.
Expand Down
4 changes: 2 additions & 2 deletions project_euler/problems/084_monopoly_odds.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ A player starts on the GO square and adds the scores on two 6-sided dice to dete
In addition to G2J, and one card from each of CC and CH, that orders the player to go directly to jail, if a player rolls three consecutive doubles, they do not advance the result of their 3rd roll. Instead they proceed directly to jail.
At the beginning of the game, the CC and CH cards are shuffled. When a player lands on CC or CH they take a card from the top of the respective pile and, after following the instructions, it is returned to the bottom of the pile. There are sixteen cards in each pile, but for the purpose of this problem we are only concerned with cards that order a movement; any instruction not concerned with movement will be ignored and the player will remain on the CC/CH square.

Community Chest (2/16 cards):
Community Chest (2/16 cards):

Advance to GO
Go to JAIL


Chance (10/16 cards):
Chance (10/16 cards):

Advance to GO
Go to JAIL
Expand Down
2 changes: 1 addition & 1 deletion project_euler/problems/090_cube_digit_pairs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In fact, by carefully choosing the digits on both cubes it is possible to displa
For example, one way this can be achieved is by placing {0, 5, 6, 7, 8, 9} on one cube and {1, 2, 3, 4, 8, 9} on the other cube.
However, for this problem we shall allow the 6 or 9 to be turned upside-down so that an arrangement like {0, 5, 6, 7, 8, 9} and {1, 2, 3, 4, 6, 7} allows for all nine square numbers to be displayed; otherwise it would be impossible to obtain 09.
In determining a distinct arrangement we are interested in the digits on each cube, not the order.
{1, 2, 3, 4, 5, 6} is equivalent to {3, 6, 4, 1, 2, 5}
{1, 2, 3, 4, 5, 6} is equivalent to {3, 6, 4, 1, 2, 5}
{1, 2, 3, 4, 5, 6} is distinct from {1, 2, 3, 4, 5, 9}
But because we are allowing 6 and 9 to be reversed, the two distinct sets in the last example both represent the extended set {1, 2, 3, 4, 5, 6, 9} for the purpose of forming 2-digit numbers.
How many distinct arrangements of the two cubes allow for all of the square numbers to be displayed?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ http://projecteuler.net/problem=141
Investigating progressive numbers, n, which are also square

A positive integer, n, is divided by d and the quotient and remainder are q and r respectively. In addition d, q, and r are consecutive positive integer terms in a geometric sequence, but not necessarily in that order.
For example, 58 divided by 6 has quotient 9 and remainder 4. It can also be seen that 4, 6, 9 are consecutive terms in a geometric sequence (common ratio 3/2).
For example, 58 divided by 6 has quotient 9 and remainder 4. It can also be seen that 4, 6, 9 are consecutive terms in a geometric sequence (common ratio 3/2).
We will call such numbers, n, progressive.
Some progressive numbers, such as 9 and 10404 = 1022, happen to also be perfect squares. The sum of all progressive perfect squares below one hundred thousand is 124657.
Find the sum of all progressive perfect squares below one trillion (1012).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Rectangles in cross-hatched grids
In a 3x2 cross-hatched grid, a total of 37 different rectangles could be situated within that grid as indicated in the sketch.

There are 5 grids smaller than 3x2, vertical and horizontal dimensions being important, i.e. 1x1, 2x1, 3x1, 1x2 and 2x2. If each of them is cross-hatched, the following number of different rectangles could be situated within those smaller grids:
1x1: 1
2x1: 4
3x1: 8
1x2: 4
1x1: 1
2x1: 4
3x1: 8
1x2: 4
2x2: 18
Adding those to the 37 of the 3x2 grid, a total of 72 different rectangles could be situated within 3x2 and smaller grids.
How many different rectangles could be situated within 47x43 and smaller grids?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Looking at the table below, it is easy to verify that the maximum possible sum o

Now, let us repeat the search, but on a much larger scale:
First, generate four million pseudo-random numbers using a specific form of what is known as a "Lagged Fibonacci Generator":
For 1 k 55, sk = [100003 200003k + 300007k3] (modulo 1000000) 500000.
For 1 k 55, sk = [100003 200003k + 300007k3] (modulo 1000000) 500000.
For 56 k 4000000, sk = [sk24 + sk55 + 1000000] (modulo 1000000) 500000.
Thus, s10 = 393027 and s100 = 86613.
The terms of s are then arranged in a 20002000 table, using the first 2000 numbers to fill the first row (sequentially), the next 2000 numbers to fill the second row, and so on.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ In the example below, it can be easily verified that the marked triangle satisfi


We wish to make such a triangular array with one thousand rows, so we generate 500500 pseudo-random numbers sk in the range 219, using a type of random number generator (known as a Linear Congruential Generator) as follows:
t := 0
for k = 1 up to k = 500500:
t := 0

for k = 1 up to k = 500500:

    t := (615949*t + 797807) modulo 220

    sk := t219
Thus: s1 = 273519, s2 = 153582, s3 = 450905 etc
Our triangular array is then formed using the pseudo-random numbers thus:

s1

s2  s3
s4  s5  s6 

s4  s5  s6

s7  s8  s9  s10

...

Sub-triangles can start at any element of the array and extend down as far as we like (taking-in the two elements directly below it from the next row, the three elements directly below from the row after that, and so on).

The "sum of a sub-triangle" is defined as the sum of all the elements it contains.

...

Sub-triangles can start at any element of the array and extend down as far as we like (taking-in the two elements directly below it from the next row, the three elements directly below from the row after that, and so on).

The "sum of a sub-triangle" is defined as the sum of all the elements it contains.

Find the smallest possible sub-triangle sum.

67 changes: 33 additions & 34 deletions project_euler/problems/153_investigating_gaussian_integers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,44 @@ http://projecteuler.net/problem=153

Investigating Gaussian Integers

As we all know the equation x2=-1 has no solutions for real x.
If we however introduce the imaginary number i this equation has two solutions: x=i and x=-i.
If we go a step further the equation (x-3)2=-4 has two complex solutions: x=3+2i and x=3-2i.

x=3+2i and x=3-2i are called each others' complex conjugate.
Numbers of the form a+bi are called complex numbers.
As we all know the equation x2=-1 has no solutions for real x.

If we however introduce the imaginary number i this equation has two solutions: x=i and x=-i.

If we go a step further the equation (x-3)2=-4 has two complex solutions: x=3+2i and x=3-2i.

x=3+2i and x=3-2i are called each others' complex conjugate.

Numbers of the form a+bi are called complex numbers.

In general a+bi and abi are each other's complex conjugate.
A Gaussian Integer is a complex number a+bi such that both a and b are integers.

The regular integers are also Gaussian integers (with b=0).

To distinguish them from Gaussian integers with b 0 we call such integers "rational integers."

A Gaussian integer is called a divisor of a rational integer n if the result is also a Gaussian integer.

If for example we divide 5 by 1+2i we can simplify in the following manner:

Multiply numerator and denominator by the complex conjugate of 1+2i: 12i.

The result is
.

So 1+2i is a divisor of 5.

Note that 1+i is not a divisor of 5 because .

A Gaussian Integer is a complex number a+bi such that both a and b are integers.

The regular integers are also Gaussian integers (with b=0).

To distinguish them from Gaussian integers with b 0 we call such integers "rational integers."

A Gaussian integer is called a divisor of a rational integer n if the result is also a Gaussian integer.

If for example we divide 5 by 1+2i we can simplify in the following manner:

Multiply numerator and denominator by the complex conjugate of 1+2i: 12i.

The result is <image>.

So 1+2i is a divisor of 5.

Note that 1+i is not a divisor of 5 because .

Note also that if the Gaussian Integer (a+bi) is a divisor of a rational integer n, then its complex conjugate (abi) is also a divisor of n.
In fact, 5 has six divisors such that the real part is positive: {1, 1 + 2i, 1 2i, 2 + i, 2 i, 5}.
In fact, 5 has six divisors such that the real part is positive: {1, 1 + 2i, 1 2i, 2 + i, 2 i, 5}.

The following is a table of all of the divisors for the first five positive rational integers:


n Gaussian integer divisors
with positive real partSum s(n) of these
n Gaussian integer divisors
with positive real partSum s(n) of these

divisors
111

Expand Down
2 changes: 1 addition & 1 deletion project_euler/problems/154_exploring_pascals_pyramid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A triangular pyramid is constructed using spherical balls so that each ball rest
Then, we calculate the number of paths leading from the apex to each position:
A path starts at the apex and progresses downwards to any of the three spheres directly below the current position.
Consequently, the number of paths to reach a certain position is the sum of the numbers immediately above it (depending on the position, there are up to three numbers above it).
The result is Pascal's pyramid and the numbers at each level n are the coefficients of the trinomial expansion
The result is Pascal's pyramid and the numbers at each level n are the coefficients of the trinomial expansion
(x + y + z)n.
How many coefficients in the expansion of (x + y + z)200000 are multiples of 1012?

10 changes: 5 additions & 5 deletions project_euler/problems/155_counting_capacitor_circuits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ http://projecteuler.net/problem=155

Counting Capacitor Circuits

An electric circuit uses exclusively identical capacitors of the same value C.
An electric circuit uses exclusively identical capacitors of the same value C.

The capacitors can be connected in series or in parallel to form sub-units, which can then be connected in series or in parallel with other capacitors or other sub-units to form larger sub-units, and so on up to a final circuit.
Using this simple procedure and up to n identical capacitors, we can make circuits having a range of different total capacitances. For example, using up to n=3 capacitors of 60 F each, we can obtain the following 7 distinct total capacitance values:

If we denote by D(n) the number of distinct total capacitance values we can obtain when using up to n equal-valued capacitors and the simple procedure described above, we have: D(1)=1, D(2)=3, D(3)=7 ...
Find D(18).
Reminder : When connecting capacitors C1, C2 etc in parallel, the total capacitance is CT = C1 + C2 +...,
whereas when connecting them in series, the overall capacitance is given by:
Reminder : When connecting capacitors C1, C2 etc in parallel, the total capacitance is CT = C1 + C2 +...,

whereas when connecting them in series, the overall capacitance is given by:


20 changes: 10 additions & 10 deletions project_euler/problems/156_counting_digits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ http://projecteuler.net/problem=156

Counting Digits

Starting from zero the natural numbers are written down in base 10 like this:
0 1 2 3 4 5 6 7 8 9 10 11 12....
Starting from zero the natural numbers are written down in base 10 like this:

0 1 2 3 4 5 6 7 8 9 10 11 12....

Consider the digit d=1. After we write down each number n, we will update the number of ones that have occurred and call this number f(n,1). The first values for f(n,1), then, are as follows:

Expand Down Expand Up @@ -38,16 +38,16 @@ nf(n,1)

125

Note that f(n,1) never equals 3.
Note that f(n,1) never equals 3.

So the first two solutions of the equation f(n,1)=n are n=0 and n=1. The next solution is n=199981.
In the same manner the function f(n,d) gives the total number of digits d that have been written down after the number n has been written.
In the same manner the function f(n,d) gives the total number of digits d that have been written down after the number n has been written.

In fact, for every digit d 0, 0 is the first solution of the equation f(n,d)=n.
Let s(d) be the sum of all the solutions for which f(n,d)=n.
Let s(d) be the sum of all the solutions for which f(n,d)=n.

You are given that s(1)=22786974071.
Find s(d) for 1 d 9.
Note: if, for some n, f(n,d)=n
Note: if, for some n, f(n,d)=n
for more than one value of d this value of n is counted again for every value of d for which f(n,d)=n.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ http://projecteuler.net/problem=157

Solving the diophantine equation 1/a+1/b= p/10n

Consider the diophantine equation 1/a+1/b= p/10n with a, b, p, n positive integers and a b.
Consider the diophantine equation 1/a+1/b= p/10n with a, b, p, n positive integers and a b.
For n=1 this equation has 20 solutions that are listed below:

1/1+1/1=20/10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ http://projecteuler.net/problem=158

Exploring strings for which only one character comes lexicographically after its neighbour to the left

Taking three different letters from the 26 letters of the alphabet, character strings of length three can be formed.
Examples are 'abc', 'hat' and 'zyx'.
When we study these three examples we see that for 'abc' two characters come lexicographically after its neighbour to the left.
For 'hat' there is exactly one character that comes lexicographically after its neighbour to the left. For 'zyx' there are zero characters that come lexicographically after its neighbour to the left.
Taking three different letters from the 26 letters of the alphabet, character strings of length three can be formed.
Examples are 'abc', 'hat' and 'zyx'.
When we study these three examples we see that for 'abc' two characters come lexicographically after its neighbour to the left.
For 'hat' there is exactly one character that comes lexicographically after its neighbour to the left. For 'zyx' there are zero characters that come lexicographically after its neighbour to the left.
In all there are 10400 strings of length 3 for which exactly one character comes lexicographically after its neighbour to the left.
We now consider strings of n 26 different characters from the alphabet.
We now consider strings of n 26 different characters from the alphabet.
For every n, p(n) is the number of strings of length n for which exactly one character comes lexicographically after its neighbour to the left.
What is the maximum value of p(n)?

32 changes: 16 additions & 16 deletions project_euler/problems/159_digital_root_sums_of_factorisations.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
http://projecteuler.net/problem=159

Digital root sums of factorisations
Digital root sums of factorisations


A composite number can be factored many different ways.
A composite number can be factored many different ways.
For instance, not including multiplication by one, 24 can be factored in 7 distinct ways:
24 = 2x2x2x3
24 = 2x3x4
24 = 2x2x6
24 = 4x6
24 = 3x8
24 = 2x12
24 = 24

Recall that the digital root of a number, in base 10, is found by adding together the digits of that number,
and repeating that process until a number is arrived at that is less than 10.

24 = 2x2x2x3
24 = 2x3x4
24 = 2x2x6
24 = 4x6
24 = 3x8
24 = 2x12
24 = 24

Recall that the digital root of a number, in base 10, is found by adding together the digits of that number,
and repeating that process until a number is arrived at that is less than 10.
Thus the digital root of 467 is 8.
We shall call a Digital Root Sum (DRS) the sum of the digital roots of the individual factors of our number.
We shall call a Digital Root Sum (DRS) the sum of the digital roots of the individual factors of our number.
The chart below demonstrates all of the DRS values for 24.

FactorisationDigital Root Sum
Expand All @@ -36,7 +36,7 @@ FactorisationDigital Root Sum
24
6

The maximum Digital Root Sum of 24 is 11.
The function mdrs(n) gives the maximum Digital Root Sum of n. So mdrs(24)=11.
The maximum Digital Root Sum of 24 is 11.
The function mdrs(n) gives the maximum Digital Root Sum of n. So mdrs(24)=11.
Find mdrs(n) for 1 n 1,000,000.

6 changes: 3 additions & 3 deletions project_euler/problems/160_factorial_trailing_digits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ http://projecteuler.net/problem=160

Factorial trailing digits

For any N, let f(N) be the last five digits before the trailing zeroes in N!.
For any N, let f(N) be the last five digits before the trailing zeroes in N!.
For example,
9! = 362880 so f(9)=36288
10! = 3628800 so f(10)=36288
9! = 362880 so f(9)=36288
10! = 3628800 so f(10)=36288
20! = 2432902008176640000 so f(20)=17664
Find f(1,000,000,000,000)

Loading