id
int64
1
981
problem
stringlengths
97
5.29k
raw_html
stringlengths
121
5.63k
url
stringlengths
34
36
answer
stringlengths
1
29
101
If we are presented with the first $k$ terms of a sequence it is impossible to say with certainty the value of the next term, as there are infinitely many polynomial functions that can model the sequence. As an example, let us consider the sequence of cube numbers. This is defined by the generating function, $u_n = n^...
<p>If we are presented with the first $k$ terms of a sequence it is impossible to say with certainty the value of the next term, as there are infinitely many polynomial functions that can model the sequence.</p> <p>As an example, let us consider the sequence of cube numbers. This is defined by the generating function,<...
https://projecteuler.net/problem=101
37076114526
102
Three distinct points are plotted at random on a Cartesian plane, for which $-1000 \le x, y \le 1000$, such that a triangle is formed. Consider the following two triangles: $$\begin{gather} A(-340,495), B(-153,-910), C(835,-947)\\ X(-175,41), Y(-421,-714), Z(574,-645) \end{gather}$$ It can be verified that triangle $...
<p>Three distinct points are plotted at random on a Cartesian plane, for which $-1000 \le x, y \le 1000$, such that a triangle is formed.</p> <p>Consider the following two triangles:</p> $$\begin{gather} A(-340,495), B(-153,-910), C(835,-947)\\ X(-175,41), Y(-421,-714), Z(574,-645) \end{gather}$$ <p>It can be verified ...
https://projecteuler.net/problem=102
228
103
Let $S(A)$ represent the sum of elements in set $A$ of size $n$. We shall call it a special sum set if for any two non-empty disjoint subsets, $B$ and $C$, the following properties are true: - $S(B) \ne S(C)$; that is, sums of subsets cannot be equal. - If $B$ contains more elements than $C$ then $S(B) \gt S(C)$. If...
<p>Let $S(A)$ represent the sum of elements in set $A$ of size $n$. We shall call it a special sum set if for any two non-empty disjoint subsets, $B$ and $C$, the following properties are true:</p> <ol><li>$S(B) \ne S(C)$; that is, sums of subsets cannot be equal.</li> <li>If $B$ contains more elements than $C$ then $S...
https://projecteuler.net/problem=103
20313839404245
104
The Fibonacci sequence is defined by the recurrence relation: $F_n = F_{n - 1} + F_{n - 2}$, where $F_1 = 1$ and $F_2 = 1$. It turns out that $F_{541}$, which contains $113$ digits, is the first Fibonacci number for which the last nine digits are $1$-$9$ pandigital (contain all the digits $1$ to $9$, but not necessari...
<p>The Fibonacci sequence is defined by the recurrence relation:</p> <blockquote>$F_n = F_{n - 1} + F_{n - 2}$, where $F_1 = 1$ and $F_2 = 1$.</blockquote> <p>It turns out that $F_{541}$, which contains $113$ digits, is the first Fibonacci number for which the last nine digits are $1$-$9$ pandigital (contain all the di...
https://projecteuler.net/problem=104
329468
105
Let $S(A)$ represent the sum of elements in set $A$ of size $n$. We shall call it a special sum set if for any two non-empty disjoint subsets, $B$ and $C$, the following properties are true: - $S(B) \ne S(C)$; that is, sums of subsets cannot be equal. - If $B$ contains more elements than $C$ then $S(B) \gt S(C)$. Fo...
<p>Let $S(A)$ represent the sum of elements in set $A$ of size $n$. We shall call it a special sum set if for any two non-empty disjoint subsets, $B$ and $C$, the following properties are true:</p> <ol><li>$S(B) \ne S(C)$; that is, sums of subsets cannot be equal.</li> <li>If $B$ contains more elements than $C$ then $S...
https://projecteuler.net/problem=105
73702
106
Let $S(A)$ represent the sum of elements in set $A$ of size $n$. We shall call it a special sum set if for any two non-empty disjoint subsets, $B$ and $C$, the following properties are true: - $S(B) \ne S(C)$; that is, sums of subsets cannot be equal. - If $B$ contains more elements than $C$ then $S(B) \gt S(C)$. Fo...
<p>Let $S(A)$ represent the sum of elements in set $A$ of size $n$. We shall call it a special sum set if for any two non-empty disjoint subsets, $B$ and $C$, the following properties are true:</p> <ol><li>$S(B) \ne S(C)$; that is, sums of subsets cannot be equal.</li> <li>If $B$ contains more elements than $C$ then $S...
https://projecteuler.net/problem=106
21384
107
The following undirected network consists of seven vertices and twelve edges with a total weight of 243. The same network can be represented by the matrix below. | | A | B | C | D | E | F | G | | A | - | 16 | 12 | 21 | - | - | - | | B | 16 | - | - | 17 | 20 | - | - | | C | 12 | - | - | 28 | - | 31 | - | | D | 21 | 1...
<p>The following undirected network consists of seven vertices and twelve edges with a total weight of 243.</p> <div class="center"> <img src="resources/images/0107_1.png?1678992052" class="dark_img" alt=""><br></div> <p>The same network can be represented by the matrix below.</p> <table cellpadding="5" cellspacing="0"...
https://projecteuler.net/problem=107
259679
108
In the following equation $x$, $y$, and $n$ are positive integers. $$\dfrac{1}{x} + \dfrac{1}{y} = \dfrac{1}{n}$$ For $n = 4$ there are exactly three distinct solutions: $$\begin{align} \dfrac{1}{5} + \dfrac{1}{20} &= \dfrac{1}{4}\\ \dfrac{1}{6} + \dfrac{1}{12} &= \dfrac{1}{4}\\ \dfrac{1}{8} + \dfrac{1}{8} &= \dfrac{...
<p>In the following equation $x$, $y$, and $n$ are positive integers.</p> $$\dfrac{1}{x} + \dfrac{1}{y} = \dfrac{1}{n}$$ <p>For $n = 4$ there are exactly three distinct solutions:</p> $$\begin{align} \dfrac{1}{5} + \dfrac{1}{20} &amp;= \dfrac{1}{4}\\ \dfrac{1}{6} + \dfrac{1}{12} &amp;= \dfrac{1}{4}\\ \dfrac{1}{8} + \df...
https://projecteuler.net/problem=108
180180
109
In the game of darts a player throws three darts at a target board which is split into twenty equal sized sections numbered one to twenty. The score of a dart is determined by the number of the region that the dart lands in. A dart landing outside the red/green outer ring scores zero. The black and cream regions insid...
<p>In the game of darts a player throws three darts at a target board which is split into twenty equal sized sections numbered one to twenty.</p> <div class="center"> <img src="resources/images/0109.png?1678992052" class="dark_img" alt=""><br></div> <p>The score of a dart is determined by the number of the region that ...
https://projecteuler.net/problem=109
38182
110
In the following equation $x$, $y$, and $n$ are positive integers. $$\dfrac{1}{x} + \dfrac{1}{y} = \dfrac{1}{n}$$ It can be verified that when $n = 1260$ there are $113$ distinct solutions and this is the least value of $n$ for which the total number of distinct solutions exceeds one hundred. What is the least value...
<p>In the following equation $x$, $y$, and $n$ are positive integers.</p> <p>$$\dfrac{1}{x} + \dfrac{1}{y} = \dfrac{1}{n}$$</p> <p>It can be verified that when $n = 1260$ there are $113$ distinct solutions and this is the least value of $n$ for which the total number of distinct solutions exceeds one hundred.</p> <p>W...
https://projecteuler.net/problem=110
9350130049860600
111
Considering $4$-digit primes containing repeated digits it is clear that they cannot all be the same: $1111$ is divisible by $11$, $2222$ is divisible by $22$, and so on. But there are nine $4$-digit primes containing three ones: $$1117, 1151, 1171, 1181, 1511, 1811, 2111, 4111, 8111.$$ We shall say that $M(n, d)$ rep...
<p>Considering $4$-digit primes containing repeated digits it is clear that they cannot all be the same: $1111$ is divisible by $11$, $2222$ is divisible by $22$, and so on. But there are nine $4$-digit primes containing three ones: $$1117, 1151, 1171, 1181, 1511, 1811, 2111, 4111, 8111.$$</p> <p>We shall say that $M(n...
https://projecteuler.net/problem=111
612407567715
112
Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, $134468$. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, $66420$. We shall call a positive integer that is neither increasing nor decr...
<p>Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, $134468$.</p> <p>Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, $66420$.</p> <p>We shall call a positive integer that is neither incr...
https://projecteuler.net/problem=112
1587000
113
Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, $134468$. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, $66420$. We shall call a positive integer that is neither increasing nor decr...
<p>Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, $134468$.</p> <p>Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, $66420$.</p> <p>We shall call a positive integer that is neither incr...
https://projecteuler.net/problem=113
51161058134250
114
A row measuring seven units in length has red blocks with a minimum length of three units placed on it, such that any two red blocks (which are allowed to be different lengths) are separated by at least one grey square. There are exactly seventeen ways of doing this. How many ways can a row measuring fifty units in le...
<p>A row measuring seven units in length has red blocks with a minimum length of three units placed on it, such that any two red blocks (which are allowed to be different lengths) are separated by at least one grey square. There are exactly seventeen ways of doing this.</p> <div class="center"> <img src="resources/ima...
https://projecteuler.net/problem=114
16475640049
115
NOTE: This is a more difficult version of Problem 114. A row measuring $n$ units in length has red blocks with a minimum length of $m$ units placed on it, such that any two red blocks (which are allowed to be different lengths) are separated by at least one black square. Let the fill-count function, $F(m, n)$, repres...
<p class="note">NOTE: This is a more difficult version of <a href="problem=114">Problem 114</a>.</p> <p>A row measuring $n$ units in length has red blocks with a minimum length of $m$ units placed on it, such that any two red blocks (which are allowed to be different lengths) are separated by at least one black square....
https://projecteuler.net/problem=115
168
116
A row of five grey square tiles is to have a number of its tiles replaced with coloured oblong tiles chosen from red (length two), green (length three), or blue (length four). If red tiles are chosen there are exactly seven ways this can be done. If green tiles are chosen there are three ways. And if blue tiles are ...
<p>A row of five grey square tiles is to have a number of its tiles replaced with coloured oblong tiles chosen from red (length two), green (length three), or blue (length four).</p> <p>If red tiles are chosen there are exactly seven ways this can be done.</p> <div class="center"> <img src="resources/images/0116_1.png...
https://projecteuler.net/problem=116
20492570929
117
Using a combination of grey square tiles and oblong tiles chosen from: red tiles (measuring two units), green tiles (measuring three units), and blue tiles (measuring four units), it is possible to tile a row measuring five units in length in exactly fifteen different ways. How many ways can a row measuring fifty unit...
<p>Using a combination of grey square tiles and oblong tiles chosen from: red tiles (measuring two units), green tiles (measuring three units), and blue tiles (measuring four units), it is possible to tile a row measuring five units in length in exactly fifteen different ways.</p> <div class="center"> <img src="resour...
https://projecteuler.net/problem=117
100808458960497
118
Using all of the digits $1$ through $9$ and concatenating them freely to form decimal integers, different sets can be formed. Interestingly with the set $\{2,5,47,89,631\}$, all of the elements belonging to it are prime. How many distinct sets containing each of the digits one through nine exactly once contain only pr...
<p>Using all of the digits $1$ through $9$ and concatenating them freely to form decimal integers, different sets can be formed. Interestingly with the set $\{2,5,47,89,631\}$, all of the elements belonging to it are prime.</p> <p>How many distinct sets containing each of the digits one through nine exactly once contai...
https://projecteuler.net/problem=118
44680
119
The number $512$ is interesting because it is equal to the sum of its digits raised to some power: $5 + 1 + 2 = 8$, and $8^3 = 512$. Another example of a number with this property is $614656 = 28^4$. We shall define $a_n$ to be the $n$th term of this sequence and insist that a number must contain at least two digits t...
<p>The number $512$ is interesting because it is equal to the sum of its digits raised to some power: $5 + 1 + 2 = 8$, and $8^3 = 512$. Another example of a number with this property is $614656 = 28^4$.</p> <p>We shall define $a_n$ to be the $n$th term of this sequence and insist that a number must contain at least two...
https://projecteuler.net/problem=119
248155780267521
120
Let $r$ be the remainder when $(a - 1)^n + (a + 1)^n$ is divided by $a^2$. For example, if $a = 7$ and $n = 3$, then $r = 42$: $6^3 + 8^3 = 728 \equiv 42 \mod 49$. And as $n$ varies, so too will $r$, but for $a = 7$ it turns out that $r_{\mathrm{max}} = 42$. For $3 \le a \le 1000$, find $\sum r_{\mathrm{max}}$.
<p>Let $r$ be the remainder when $(a - 1)^n + (a + 1)^n$ is divided by $a^2$.</p> <p>For example, if $a = 7$ and $n = 3$, then $r = 42$: $6^3 + 8^3 = 728 \equiv 42 \mod 49$. And as $n$ varies, so too will $r$, but for $a = 7$ it turns out that $r_{\mathrm{max}} = 42$.</p> <p>For $3 \le a \le 1000$, find $\sum r_{\mathr...
https://projecteuler.net/problem=120
333082500
121
A bag contains one red disc and one blue disc. In a game of chance a player takes a disc at random and its colour is noted. After each turn the disc is returned to the bag, an extra red disc is added, and another disc is taken at random. The player pays £1 to play and wins if they have taken more blue discs than red d...
<p>A bag contains one red disc and one blue disc. In a game of chance a player takes a disc at random and its colour is noted. After each turn the disc is returned to the bag, an extra red disc is added, and another disc is taken at random.</p> <p>The player pays £1 to play and wins if they have taken more blue discs t...
https://projecteuler.net/problem=121
2269
122
The most naive way of computing $n^{15}$ requires fourteen multiplications: $$n \times n \times \cdots \times n = n^{15}.$$ But using a "binary" method you can compute it in six multiplications: $$\begin{align} n \times n &= n^2\\ n^2 \times n^2 &= n^4\\ n^4 \times n^4 &= n^8\\ n^8 \times n^4 &= n^{12}\\ n^{12} \time...
<p>The most naive way of computing $n^{15}$ requires fourteen multiplications: $$n \times n \times \cdots \times n = n^{15}.$$</p> <p>But using a "binary" method you can compute it in six multiplications:</p> $$\begin{align} n \times n &amp;= n^2\\ n^2 \times n^2 &amp;= n^4\\ n^4 \times n^4 &amp;= n^8\\ n^8 \times n^4 ...
https://projecteuler.net/problem=122
1582
123
Let $p_n$ be the $n$th prime: $2, 3, 5, 7, 11, \dots$, and let $r$ be the remainder when $(p_n - 1)^n + (p_n + 1)^n$ is divided by $p_n^2$. For example, when $n = 3$, $p_3 = 5$, and $4^3 + 6^3 = 280 \equiv 5 \mod 25$. The least value of $n$ for which the remainder first exceeds $10^9$ is $7037$. Find the least value...
<p>Let $p_n$ be the $n$th prime: $2, 3, 5, 7, 11, \dots$, and let $r$ be the remainder when $(p_n - 1)^n + (p_n + 1)^n$ is divided by $p_n^2$.</p> <p>For example, when $n = 3$, $p_3 = 5$, and $4^3 + 6^3 = 280 \equiv 5 \mod 25$.</p> <p>The least value of $n$ for which the remainder first exceeds $10^9$ is $7037$.</p> <p...
https://projecteuler.net/problem=123
21035
124
The radical of $n$, $\operatorname{rad}(n)$, is the product of the distinct prime factors of $n$. For example, $504 = 2^3 \times 3^2 \times 7$, so $\operatorname{rad}(504) = 2 \times 3 \times 7 = 42$. If we calculate $\operatorname{rad}(n)$ for $1 \le n \le 10$, then sort them on $\operatorname{rad}(n)$, and sorting o...
<p>The radical of $n$, $\operatorname{rad}(n)$, is the product of the distinct prime factors of $n$. For example, $504 = 2^3 \times 3^2 \times 7$, so $\operatorname{rad}(504) = 2 \times 3 \times 7 = 42$.</p> <p>If we calculate $\operatorname{rad}(n)$ for $1 \le n \le 10$, then sort them on $\operatorname{rad}(n)$, and ...
https://projecteuler.net/problem=124
21417
125
The palindromic number $595$ is interesting because it can be written as the sum of consecutive squares: $6^2 + 7^2 + 8^2 + 9^2 + 10^2 + 11^2 + 12^2$. There are exactly eleven palindromes below one-thousand that can be written as consecutive square sums, and the sum of these palindromes is $4164$. Note that $1 = 0^2 +...
<p>The palindromic number $595$ is interesting because it can be written as the sum of consecutive squares: $6^2 + 7^2 + 8^2 + 9^2 + 10^2 + 11^2 + 12^2$.</p> <p>There are exactly eleven palindromes below one-thousand that can be written as consecutive square sums, and the sum of these palindromes is $4164$. Note that $...
https://projecteuler.net/problem=125
2906969179
126
The minimum number of cubes to cover every visible face on a cuboid measuring $3 \times 2 \times 1$ is twenty-two. If we then add a second layer to this solid it would require forty-six cubes to cover every visible face, the third layer would require seventy-eight cubes, and the fourth layer would require one-hundred ...
<p>The minimum number of cubes to cover every visible face on a cuboid measuring $3 \times 2 \times 1$ is twenty-two.</p> <div class="center"> <img src="resources/images/0126.png?1678992052" class="dark_img" alt=""><br></div> <p>If we then add a second layer to this solid it would require forty-six cubes to cover every...
https://projecteuler.net/problem=126
18522
127
The radical of $n$, $\operatorname{rad}(n)$, is the product of distinct prime factors of $n$. For example, $504 = 2^3 \times 3^2 \times 7$, so $\operatorname{rad}(504) = 2 \times 3 \times 7 = 42$. We shall define the triplet of positive integers $(a, b, c)$ to be an abc-hit if: - $\gcd(a, b) = \gcd(a, c) = \gcd(b, c)...
<p>The radical of $n$, $\operatorname{rad}(n)$, is the product of distinct prime factors of $n$. For example, $504 = 2^3 \times 3^2 \times 7$, so $\operatorname{rad}(504) = 2 \times 3 \times 7 = 42$.</p> <p>We shall define the triplet of positive integers $(a, b, c)$ to be an abc-hit if:</p> <ol><li>$\gcd(a, b) = \gcd(...
https://projecteuler.net/problem=127
18407904
128
A hexagonal tile with number $1$ is surrounded by a ring of six hexagonal tiles, starting at "12 o'clock" and numbering the tiles $2$ to $7$ in an anti-clockwise direction. New rings are added in the same fashion, with the next rings being numbered $8$ to $19$, $20$ to $37$, $38$ to $61$, and so on. The diagram below ...
<p>A hexagonal tile with number $1$ is surrounded by a ring of six hexagonal tiles, starting at "12 o'clock" and numbering the tiles $2$ to $7$ in an anti-clockwise direction.</p> <p>New rings are added in the same fashion, with the next rings being numbered $8$ to $19$, $20$ to $37$, $38$ to $61$, and so on. The diagr...
https://projecteuler.net/problem=128
14516824220
129
A number consisting entirely of ones is called a repunit. We shall define $R(k)$ to be a repunit of length $k$; for example, $R(6) = 111111$. Given that $n$ is a positive integer and $\gcd(n, 10) = 1$, it can be shown that there always exists a value, $k$, for which $R(k)$ is divisible by $n$, and let $A(n)$ be the le...
<p>A number consisting entirely of ones is called a repunit. We shall define $R(k)$ to be a repunit of length $k$; for example, $R(6) = 111111$.</p> <p>Given that $n$ is a positive integer and $\gcd(n, 10) = 1$, it can be shown that there always exists a value, $k$, for which $R(k)$ is divisible by $n$, and let $A(n)$ ...
https://projecteuler.net/problem=129
1000023
130
A number consisting entirely of ones is called a repunit. We shall define $R(k)$ to be a repunit of length $k$; for example, $R(6) = 111111$. Given that $n$ is a positive integer and $\gcd(n, 10) = 1$, it can be shown that there always exists a value, $k$, for which $R(k)$ is divisible by $n$, and let $A(n)$ be the le...
<p>A number consisting entirely of ones is called a repunit. We shall define $R(k)$ to be a repunit of length $k$; for example, $R(6) = 111111$.</p> <p>Given that $n$ is a positive integer and $\gcd(n, 10) = 1$, it can be shown that there always exists a value, $k$, for which $R(k)$ is divisible by $n$, and let $A(n)$ ...
https://projecteuler.net/problem=130
149253
131
There are some prime values, $p$, for which there exists a positive integer, $n$, such that the expression $n^3 + n^2p$ is a perfect cube. For example, when $p = 19$, $8^3 + 8^2 \times 19 = 12^3$. What is perhaps most surprising is that for each prime with this property the value of $n$ is unique, and there are only ...
<p>There are some prime values, $p$, for which there exists a positive integer, $n$, such that the expression $n^3 + n^2p$ is a perfect cube.</p> <p>For example, when $p = 19$, $8^3 + 8^2 \times 19 = 12^3$.</p> <p>What is perhaps most surprising is that for each prime with this property the value of $n$ is unique, and ...
https://projecteuler.net/problem=131
173
132
A number consisting entirely of ones is called a repunit. We shall define $R(k)$ to be a repunit of length $k$. For example, $R(10) = 1111111111 = 11 \times 41 \times 271 \times 9091$, and the sum of these prime factors is $9414$. Find the sum of the first forty prime factors of $R(10^9)$.
<p>A number consisting entirely of ones is called a repunit. We shall define $R(k)$ to be a repunit of length $k$.</p> <p>For example, $R(10) = 1111111111 = 11 \times 41 \times 271 \times 9091$, and the sum of these prime factors is $9414$.</p> <p>Find the sum of the first forty prime factors of $R(10^9)$.</p>
https://projecteuler.net/problem=132
843296
133
A number consisting entirely of ones is called a repunit. We shall define $R(k)$ to be a repunit of length $k$; for example, $R(6) = 111111$. Let us consider repunits of the form $R(10^n)$. Although $R(10)$, $R(100)$, or $R(1000)$ are not divisible by $17$, $R(10000)$ is divisible by $17$. Yet there is no value of $n...
<p>A number consisting entirely of ones is called a repunit. We shall define $R(k)$ to be a repunit of length $k$; for example, $R(6) = 111111$.</p> <p>Let us consider repunits of the form $R(10^n)$.</p> <p>Although $R(10)$, $R(100)$, or $R(1000)$ are not divisible by $17$, $R(10000)$ is divisible by $17$. Yet there is...
https://projecteuler.net/problem=133
453647705
134
Consider the consecutive primes $p_1 = 19$ and $p_2 = 23$. It can be verified that $1219$ is the smallest number such that the last digits are formed by $p_1$ whilst also being divisible by $p_2$. In fact, with the exception of $p_1 = 3$ and $p_2 = 5$, for every pair of consecutive primes, $p_2 \gt p_1$, there exist v...
<p>Consider the consecutive primes $p_1 = 19$ and $p_2 = 23$. It can be verified that $1219$ is the smallest number such that the last digits are formed by $p_1$ whilst also being divisible by $p_2$.</p> <p>In fact, with the exception of $p_1 = 3$ and $p_2 = 5$, for every pair of consecutive primes, $p_2 \gt p_1$, ther...
https://projecteuler.net/problem=134
18613426663617118
135
Given the positive integers, $x$, $y$, and $z$, are consecutive terms of an arithmetic progression, the least value of the positive integer, $n$, for which the equation, $x^2 - y^2 - z^2 = n$, has exactly two solutions is $n = 27$: $$34^2 - 27^2 - 20^2 = 12^2 - 9^2 - 6^2 = 27.$$ It turns out that $n = 1155$ is the lea...
<p>Given the positive integers, $x$, $y$, and $z$, are consecutive terms of an arithmetic progression, the least value of the positive integer, $n$, for which the equation, $x^2 - y^2 - z^2 = n$, has exactly two solutions is $n = 27$: $$34^2 - 27^2 - 20^2 = 12^2 - 9^2 - 6^2 = 27.$$</p> <p>It turns out that $n = 1155$ i...
https://projecteuler.net/problem=135
4989
136
The positive integers, $x$, $y$, and $z$, are consecutive terms of an arithmetic progression. Given that $n$ is a positive integer, the equation, $x^2 - y^2 - z^2 = n$, has exactly one solution when $n = 20$: $$13^2 - 10^2 - 7^2 = 20.$$ In fact there are twenty-five values of $n$ below one hundred for which the equati...
<p>The positive integers, $x$, $y$, and $z$, are consecutive terms of an arithmetic progression. Given that $n$ is a positive integer, the equation, $x^2 - y^2 - z^2 = n$, has exactly one solution when $n = 20$: $$13^2 - 10^2 - 7^2 = 20.$$</p> <p>In fact there are twenty-five values of $n$ below one hundred for which t...
https://projecteuler.net/problem=136
2544559
137
Consider the infinite polynomial series $A_F(x) = x F_1 + x^2 F_2 + x^3 F_3 + \dots$, where $F_k$ is the $k$th term in the Fibonacci sequence: $1, 1, 2, 3, 5, 8, \dots$; that is, $F_k = F_{k-1} + F_{k-2}$, $F_1 = 1$ and $F_2 = 1$. For this problem we shall be interested in values of $x$ for which $A_F(x)$ is a positiv...
<p>Consider the infinite polynomial series $A_F(x) = x F_1 + x^2 F_2 + x^3 F_3 + \dots$, where $F_k$ is the $k$th term in the Fibonacci sequence: $1, 1, 2, 3, 5, 8, \dots$; that is, $F_k = F_{k-1} + F_{k-2}$, $F_1 = 1$ and $F_2 = 1$.</p> <p>For this problem we shall be interested in values of $x$ for which $A_F(x)$ is ...
https://projecteuler.net/problem=137
1120149658760
138
Consider the isosceles triangle with base length, $b = 16$, and legs, $L = 17$. By using the Pythagorean theorem it can be seen that the height of the triangle, $h = \sqrt{17^2 - 8^2} = 15$, which is one less than the base length. With $b = 272$ and $L = 305$, we get $h = 273$, which is one more than the base length,...
<p>Consider the isosceles triangle with base length, $b = 16$, and legs, $L = 17$.</p> <div class="center"> <img src="resources/images/0138.png?1678992052" width="230" height="228" class="dark_img" alt=""></div> <p>By using the Pythagorean theorem it can be seen that the height of the triangle, $h = \sqrt{17^2 - 8^2} =...
https://projecteuler.net/problem=138
1118049290473932
139
Let $(a, b, c)$ represent the three sides of a right angle triangle with integral length sides. It is possible to place four such triangles together to form a square with length $c$. For example, $(3, 4, 5)$ triangles can be placed together to form a $5$ by $5$ square with a $1$ by $1$ hole in the middle and it can be...
<p>Let $(a, b, c)$ represent the three sides of a right angle triangle with integral length sides. It is possible to place four such triangles together to form a square with length $c$.</p> <p>For example, $(3, 4, 5)$ triangles can be placed together to form a $5$ by $5$ square with a $1$ by $1$ hole in the middle and ...
https://projecteuler.net/problem=139
10057761
140
Consider the infinite polynomial series $A_G(x) = x G_1 + x^2 G_2 + x^3 G_3 + \cdots$, where $G_k$ is the $k$th term of the second order recurrence relation $G_k = G_{k-1} + G_{k-2}$, $G_1 = 1$ and $G_2 = 4$; that is, $1, 4, 5, 9, 14, 23, \dots$. For this problem we shall be concerned with values of $x$ for which $A_G...
<p>Consider the infinite polynomial series $A_G(x) = x G_1 + x^2 G_2 + x^3 G_3 + \cdots$, where $G_k$ is the $k$th term of the second order recurrence relation $G_k = G_{k-1} + G_{k-2}$, $G_1 = 1$ and $G_2 = 4$; that is, $1, 4, 5, 9, 14, 23, \dots$.</p> <p>For this problem we shall be concerned with values of $x$ for w...
https://projecteuler.net/problem=140
5673835352990
141
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 se...
<p>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.</p> <p>For example, $58$ divided by $6$ has quotient $9$ and remainder $4$. It can a...
https://projecteuler.net/problem=141
878454337159
142
Find the smallest $x + y + z$ with integers $x \gt y \gt z \gt 0$ such that $x + y$, $x - y$, $x + z$, $x - z$, $y + z$, $y - z$ are all perfect squares.
<p>Find the smallest $x + y + z$ with integers $x \gt y \gt z \gt 0$ such that $x + y$, $x - y$, $x + z$, $x - z$, $y + z$, $y - z$ are all perfect squares.</p>
https://projecteuler.net/problem=142
1006193
143
Let $ABC$ be a triangle with all interior angles being less than $120$ degrees. Let $X$ be any point inside the triangle and let $XA = p$, $XC = q$, and $XB = r$. Fermat challenged Torricelli to find the position of $X$ such that $p + q + r$ was minimised. Torricelli was able to prove that if equilateral triangles $A...
<p>Let $ABC$ be a triangle with all interior angles being less than $120$ degrees. Let $X$ be any point inside the triangle and let $XA = p$, $XC = q$, and $XB = r$.</p> <p>Fermat challenged Torricelli to find the position of $X$ such that $p + q + r$ was minimised.</p> <p>Torricelli was able to prove that if equilater...
https://projecteuler.net/problem=143
30758397
144
In laser physics, a "white cell" is a mirror system that acts as a delay line for the laser beam. The beam enters the cell, bounces around on the mirrors, and eventually works its way back out. The specific white cell we will be considering is an ellipse with the equation $4x^2 + y^2 = 100$. The section corresponding...
<p>In laser physics, a "white cell" is a mirror system that acts as a delay line for the laser beam. The beam enters the cell, bounces around on the mirrors, and eventually works its way back out.</p> <p>The specific white cell we will be considering is an ellipse with the equation $4x^2 + y^2 = 100$.</p> <p>The sectio...
https://projecteuler.net/problem=144
354
145
Some positive integers $n$ have the property that the sum $[n + \operatorname{reverse}(n)]$ consists entirely of odd (decimal) digits. For instance, $36 + 63 = 99$ and $409 + 904 = 1313$. We will call such numbers reversible; so $36$, $63$, $409$, and $904$ are reversible. Leading zeroes are not allowed in either $n$ o...
<p>Some positive integers $n$ have the property that the sum $[n + \operatorname{reverse}(n)]$ consists entirely of odd (decimal) digits. For instance, $36 + 63 = 99$ and $409 + 904 = 1313$. We will call such numbers <dfn>reversible</dfn>; so $36$, $63$, $409$, and $904$ are reversible. Leading zeroes are not allowed i...
https://projecteuler.net/problem=145
608720
146
The smallest positive integer $n$ for which the numbers $n^2 + 1$, $n^2 + 3$, $n^2 + 7$, $n^2 + 9$, $n^2 + 13$, and $n^2 + 27$ are consecutive primes is $10$. The sum of all such integers $n$ below one-million is $1242490$. What is the sum of all such integers $n$ below $150$ million?
<p>The smallest positive integer $n$ for which the numbers $n^2 + 1$, $n^2 + 3$, $n^2 + 7$, $n^2 + 9$, $n^2 + 13$, and $n^2 + 27$ are consecutive primes is $10$. The sum of all such integers $n$ below one-million is $1242490$.</p> <p>What is the sum of all such integers $n$ below $150$ million?</p>
https://projecteuler.net/problem=146
676333270
147
In a $3 \times 2$ 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 $3 \times 2$, vertical and horizontal dimensions being important, i.e. $1 \times 1$, $2 \times 1$, $3 \times 1$, $1 \times 2$ and $2 \times 2$. If e...
<p>In a $3 \times 2$ cross-hatched grid, a total of $37$ different rectangles could be situated within that grid as indicated in the sketch.</p> <div class="center"><img src="resources/images/0147.png?1678992052" class="dark_img" alt=""></div> <p>There are $5$ grids smaller than $3 \times 2$, vertical and horizontal di...
https://projecteuler.net/problem=147
846910284
148
We can easily verify that none of the entries in the first seven rows of Pascal's triangle are divisible by $7$: | | | | | | | $1$ | | | | | | | | | | | | | $1$ | | $1$ | | | | | | | | | | | $1$ | | $2$ | | $1$ | | | | | | | | | $1$ | | $3$ | | $3$ | | $1$ | | | | | | | $1$ ...
<p>We can easily verify that none of the entries in the first seven rows of Pascal's triangle are divisible by $7$:</p> <table align="center"><tr> <td align="center" width="15"></td> <td align="center" width="15"></td> <td align="center" width="15"></td> <td align="center" width="15"></td> <td align="center" width="15...
https://projecteuler.net/problem=148
2129970655314432
149
Looking at the table below, it is easy to verify that the maximum possible sum of adjacent numbers in any direction (horizontal, vertical, diagonal or anti-diagonal) is $16$ ($= 8 + 7 + 1$). | $-2$ | $5$ | $3$ | $2$ | | $9$ | $-6$ | $5$ | $1$ | | $3$ | $2$ | $7$ | $3$ | | $-1$ | $8$ | $-4$ | $8$ | Now, let us repeat ...
<p>Looking at the table below, it is easy to verify that the maximum possible sum of adjacent numbers in any direction (horizontal, vertical, diagonal or anti-diagonal) <span style="white-space:nowrap;">is $16$ ($= 8 + 7 + 1$).</span></p> <div class="center"> <table border="1" cellpadding="6" cellspacing="0" style="ma...
https://projecteuler.net/problem=149
52852124
150
In a triangular array of positive and negative integers, we wish to find a sub-triangle such that the sum of the numbers it contains is the smallest possible. In the example below, it can be easily verified that the marked triangle satisfies this condition having a sum of −42. We wish to make such a triangular array ...
<p>In a triangular array of positive and negative integers, we wish to find a sub-triangle such that the sum of the numbers it contains is the smallest possible.</p> <p>In the example below, it can be easily verified that the marked triangle satisfies this condition having a sum of −42.</p> <div class="center"> <img sr...
https://projecteuler.net/problem=150
-271248680
151
A printing shop runs 16 batches (jobs) every week and each batch requires a sheet of special colour-proofing paper of size A5. Every Monday morning, the supervisor opens a new envelope, containing a large sheet of the special paper with size A1. The supervisor proceeds to cut it in half, thus getting two sheets of si...
<p>A printing shop runs 16 batches (jobs) every week and each batch requires a sheet of special colour-proofing paper of size A5.</p> <p>Every Monday morning, the supervisor opens a new envelope, containing a large sheet of the special paper with size A1.</p> <p>The supervisor proceeds to cut it in half, thus getting...
https://projecteuler.net/problem=151
0.464399
152
There are several ways to write the number $\dfrac{1}{2}$ as a sum of square reciprocals using distinct integers. For instance, the numbers $\{2,3,4,5,7,12,15,20,28,35\}$ can be used: $$\begin{align}\dfrac{1}{2} &= \dfrac{1}{2^2} + \dfrac{1}{3^2} + \dfrac{1}{4^2} + \dfrac{1}{5^2} +\\ &\quad \dfrac{1}{7^2} + \dfrac{1}...
<p>There are several ways to write the number $\dfrac{1}{2}$ as a sum of square reciprocals using <i>distinct</i> integers.</p> <p>For instance, the numbers $\{2,3,4,5,7,12,15,20,28,35\}$ can be used:</p> <p>$$\begin{align}\dfrac{1}{2} &amp;= \dfrac{1}{2^2} + \dfrac{1}{3^2} + \dfrac{1}{4^2} + \dfrac{1}{5^2} +\\ &amp;\q...
https://projecteuler.net/problem=152
301
153
As we all know the equation $x^2=-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' com...
<p>As we all know the equation $x^2=-1$ has no solutions for real $x$. <br> If we however introduce the imaginary number $i$ this equation has two solutions: $x=i$ and $x=-i$. <br> If we go a step further the equation $(x-3)^2=-4$ has two complex solutions: $x=3+2i$ and $x=3-2i$. <br>$x=3+2i$ and $x=3-2i$ are called ea...
https://projecteuler.net/problem=153
17971254122360635
154
A triangular pyramid is constructed using spherical balls so that each ball rests on exactly three balls of the next lower level. 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 pos...
<p>A triangular pyramid is constructed using spherical balls so that each ball rests on exactly three balls of the next lower level.</p> <div class="center"><img src="resources/images/0154_pyramid.png?1678992052" class="dark_img" alt=""></div> <p>Then, we calculate the number of paths leading from the apex to each posi...
https://projecteuler.net/problem=154
479742450
155
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 th...
<p>An electric circuit uses exclusively identical capacitors of the same value $C$. <br> 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.</p...
https://projecteuler.net/problem=155
3857447
156
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\cdots$$ 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...
<p>Starting from zero the natural numbers are written down in base $10$ like this: <br> $$0\,1\,2\,3\,4\,5\,6\,7\,8\,9\,10\,11\,12\cdots$$ </p> <p>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,...
https://projecteuler.net/problem=156
21295121502550
157
Consider the diophantine equation $\frac 1 a + \frac 1 b = \frac p {10^n}$ with $a, b, p, n$ positive integers and $a \le b$. For $n=1$ this equation has $20$ solutions that are listed below: $$\begin{matrix} \frac 1 1 + \frac 1 1 = \frac{20}{10} & \frac 1 1 + \frac 1 2 = \frac{15}{10} & \frac 1 1 + \frac 1 5 = \frac{...
<p>Consider the diophantine equation $\frac 1 a + \frac 1 b = \frac p {10^n}$ with $a, b, p, n$ positive integers and $a \le b$.<br> For $n=1$ this equation has $20$ solutions that are listed below: $$\begin{matrix} \frac 1 1 + \frac 1 1 = \frac{20}{10} &amp; \frac 1 1 + \frac 1 2 = \frac{15}{10} &amp; \frac 1 1 + \fra...
https://projecteuler.net/problem=157
53490
158
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 ch...
<p>Taking three different letters from the $26$ letters of the alphabet, character strings of length three can be formed.<br> Examples are 'abc', 'hat' and 'zyx'.<br> When we study these three examples we see that for 'abc' two characters come lexicographically after its neighbour to the left.<br> For 'hat' there is e...
https://projecteuler.net/problem=158
409511334375
159
A composite number can be factored many different ways. For instance, not including multiplication by one, $24$ can be factored in $7$ distinct ways: $$\begin{align} 24 &= 2 \times 2 \times 2 \times 3\\ 24 &= 2 \times 3 \times 4\\ 24 &= 2 \times 2 \times 6\\ 24 &= 4 \times 6\\ 24 &= 3 \times 8\\ 24 &= 2 \times 12\\ 24...
<p>A composite number can be factored many different ways. For instance, not including multiplication by one, $24$ can be factored in $7$ distinct ways:</p> $$\begin{align} 24 &amp;= 2 \times 2 \times 2 \times 3\\ 24 &amp;= 2 \times 3 \times 4\\ 24 &amp;= 2 \times 2 \times 6\\ 24 &amp;= 4 \times 6\\ 24 &amp;= 3 \time...
https://projecteuler.net/problem=159
14489159
160
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$ - $20! = 2432902008176640000$ so $f(20)=17664$ Find $f(1\,000\,000\,000\,000)$.
<p>For any $N$, let $f(N)$ be the last five digits before the trailing zeroes in $N!$.<br> For example,</p> <ul style="list-style-type:none;"> <li>$9! = 362880$ so $f(9)=36288$</li> <li>$10! = 3628800$ so $f(10)=36288$</li> <li>$20! = 2432902008176640000$ so $f(20)=17664$</li></ul> <p>Find $f(1\,000\,000\,000\,000)$.</...
https://projecteuler.net/problem=160
16576
161
A triomino is a shape consisting of three squares joined via the edges. There are two basic forms: If all possible orientations are taken into account there are six: Any $n$ by $m$ grid for which $n \times m$ is divisible by $3$ can be tiled with triominoes. If we consider tilings that can be obtained by reflection ...
<p>A triomino is a shape consisting of three squares joined via the edges. There are two basic forms:</p> <p class="center"><img src="resources/images/0161_trio1.gif?1678992055" class="dark_img" alt=""></p> <p>If all possible orientations are taken into account there are six:</p> <p class="center"><img src="resource...
https://projecteuler.net/problem=161
20574308184277971
162
In the hexadecimal number system numbers are represented using $16$ different digits: $$0,1,2,3,4,5,6,7,8,9,\mathrm A,\mathrm B,\mathrm C,\mathrm D,\mathrm E,\mathrm F.$$ The hexadecimal number $\mathrm{AF}$ when written in the decimal number system equals $10 \times 16 + 15 = 175$. In the $3$-digit hexadecimal numbe...
<p>In the hexadecimal number system numbers are represented using $16$ different digits: $$0,1,2,3,4,5,6,7,8,9,\mathrm A,\mathrm B,\mathrm C,\mathrm D,\mathrm E,\mathrm F.$$</p> <p>The hexadecimal number $\mathrm{AF}$ when written in the decimal number system equals $10 \times 16 + 15 = 175$.</p> <p>In the $3$-digit he...
https://projecteuler.net/problem=162
3D58725572C62302
163
Consider an equilateral triangle in which straight lines are drawn from each vertex to the middle of the opposite side, such as in the size $1$ triangle in the sketch below. Sixteen triangles of either different shape or size or orientation or location can now be observed in that triangle. Using size $1$ triangles as ...
<p>Consider an equilateral triangle in which straight lines are drawn from each vertex to the middle of the opposite side, such as in the <i>size $1$</i> triangle in the sketch below.</p> <div class="center"><img src="resources/images/0163.gif?1678992055" class="dark_img" alt=""></div> <p>Sixteen triangles of either di...
https://projecteuler.net/problem=163
343047
164
How many $20$ digit numbers $n$ (without any leading zero) exist such that no three consecutive digits of $n$ have a sum greater than $9$?
<p>How many $20$ digit numbers $n$ (without any leading zero) exist such that no three consecutive digits of $n$ have a sum greater than $9$?</p>
https://projecteuler.net/problem=164
378158756814587
165
A segment is uniquely defined by its two endpoints. By considering two line segments in plane geometry there are three possibilities: the segments have zero points, one point, or infinitely many points in common. Moreover when two segments have exactly one point in common it might be the case that that common point i...
<p>A segment is uniquely defined by its two endpoints.<br> By considering two line segments in plane geometry there are three possibilities:<br> the segments have zero points, one point, or infinitely many points in common.</p> <p>Moreover when two segments have exactly one point in common it might be the case that th...
https://projecteuler.net/problem=165
2868868
166
A $4 \times 4$ grid is filled with digits $d$, $0 \le d \le 9$. It can be seen that in the grid $$\begin{matrix} 6 & 3 & 3 & 0\\ 5 & 0 & 4 & 3\\ 0 & 7 & 1 & 4\\ 1 & 2 & 4 & 5 \end{matrix}$$ the sum of each row and each column has the value $12$. Moreover the sum of each diagonal is also $12$. In how many ways can you...
<p>A $4 \times 4$ grid is filled with digits $d$, $0 \le d \le 9$.</p> <p>It can be seen that in the grid $$\begin{matrix} 6 &amp; 3 &amp; 3 &amp; 0\\ 5 &amp; 0 &amp; 4 &amp; 3\\ 0 &amp; 7 &amp; 1 &amp; 4\\ 1 &amp; 2 &amp; 4 &amp; 5 \end{matrix}$$ the sum of each row and each column has the value $12$. Moreover the su...
https://projecteuler.net/problem=166
7130034
167
For two positive integers $a$ and $b$, the Ulam sequence $U(a,b)$ is defined by $U(a,b)_1 = a$, $U(a,b)_2 = b$ and for $k \gt 2$, $U(a,b)_k$ is the smallest integer greater than $U(a,b)_{k - 1}$ which can be written in exactly one way as the sum of two distinct previous members of $U(a,b)$. For example, the sequence $...
<p>For two positive integers $a$ and $b$, the Ulam sequence $U(a,b)$ is defined by $U(a,b)_1 = a$, $U(a,b)_2 = b$ and for $k \gt 2$, $U(a,b)_k$ is the smallest integer greater than $U(a,b)_{k - 1}$ which can be written in exactly one way as the sum of two distinct previous members of $U(a,b)$.</p> <p>For example, the s...
https://projecteuler.net/problem=167
3916160068885
168
Consider the number $142857$. We can right-rotate this number by moving the last digit ($7$) to the front of it, giving us $714285$. It can be verified that $714285 = 5 \times 142857$. This demonstrates an unusual property of $142857$: it is a divisor of its right-rotation. Find the last $5$ digits of the sum of all...
<p>Consider the number $142857$. We can right-rotate this number by moving the last digit ($7$) to the front of it, giving us $714285$.<br> It can be verified that $714285 = 5 \times 142857$.<br> This demonstrates an unusual property of $142857$: it is a divisor of its right-rotation.</p> <p>Find the last $5$ digits of...
https://projecteuler.net/problem=168
59206
169
Define $f(0)=1$ and $f(n)$ to be the number of different ways $n$ can be expressed as a sum of integer powers of $2$ using each power no more than twice. For example, $f(10)=5$ since there are five different ways to express $10$: $$\begin{align} & 1 + 1 + 8\\ & 1 + 1 + 4 + 4\\ & 1 + 1 + 2 + 2 + 4\\ & 2 + 4 + 4\\ & 2 ...
<p>Define $f(0)=1$ and $f(n)$ to be the number of different ways $n$ can be expressed as a sum of integer powers of $2$ using each power no more than twice.</p> <p>For example, $f(10)=5$ since there are five different ways to express $10$:</p> $$\begin{align} &amp; 1 + 1 + 8\\ &amp; 1 + 1 + 4 + 4\\ &amp; 1 + 1 + 2 + 2 ...
https://projecteuler.net/problem=169
178653872807
170
Take the number $6$ and multiply it by each of $1273$ and $9854$: $$\begin{align} 6 \times 1273 &= 7638\\ 6 \times 9854 &= 59124 \end{align}$$ By concatenating these products we get the $1$ to $9$ pandigital $763859124$. We will call $763859124$ the "concatenated product of $6$ and $(1273,9854)$". Notice too, that th...
<p>Take the number $6$ and multiply it by each of $1273$ and $9854$:</p> $$\begin{align} 6 \times 1273 &amp;= 7638\\ 6 \times 9854 &amp;= 59124 \end{align}$$ <p>By concatenating these products we get the $1$ to $9$ pandigital $763859124$. We will call $763859124$ the "concatenated product of $6$ and $(1273,9854)$". N...
https://projecteuler.net/problem=170
9857164023
171
For a positive integer $n$, let $f(n)$ be the sum of the squares of the digits (in base $10$) of $n$, e.g. $$\begin{align} f(3) &= 3^2 = 9,\\ f(25) &= 2^2 + 5^2 = 4 + 25 = 29,\\ f(442) &= 4^2 + 4^2 + 2^2 = 16 + 16 + 4 = 36\\ \end{align}$$ Find the last nine digits of the sum of all $n$, $0 \lt n \lt 10^{20}$, such tha...
<p>For a positive integer $n$, let $f(n)$ be the sum of the squares of the digits (in base $10$) of $n$, e.g.</p> $$\begin{align} f(3) &amp;= 3^2 = 9,\\ f(25) &amp;= 2^2 + 5^2 = 4 + 25 = 29,\\ f(442) &amp;= 4^2 + 4^2 + 2^2 = 16 + 16 + 4 = 36\\ \end{align}$$ <p>Find the last nine digits of the sum of all $n$, $0 \lt n \...
https://projecteuler.net/problem=171
142989277
172
How many $18$-digit numbers $n$ (without leading zeros) are there such that no digit occurs more than three times in $n$?
<p>How many $18$-digit numbers $n$ (without leading zeros) are there such that no digit occurs more than three times in $n$?</p>
https://projecteuler.net/problem=172
227485267000992000
173
We shall define a square lamina to be a square outline with a square "hole" so that the shape possesses vertical and horizontal symmetry. For example, using exactly thirty-two square tiles we can form two different square laminae: With one-hundred tiles, and not necessarily using all of the tiles at one time, it is po...
<p>We shall define a square lamina to be a square outline with a square "hole" so that the shape possesses vertical and horizontal symmetry. For example, using exactly thirty-two square tiles we can form two different square laminae:</p> <div class="center"> <img src="resources/images/0173_square_laminas.gif?1678992055...
https://projecteuler.net/problem=173
1572729
174
We shall define a square lamina to be a square outline with a square "hole" so that the shape possesses vertical and horizontal symmetry. Given eight tiles it is possible to form a lamina in only one way: $3 \times 3$ square with a $1 \times 1$ hole in the middle. However, using thirty-two tiles it is possible to form...
<p>We shall define a square lamina to be a square outline with a square "hole" so that the shape possesses vertical and horizontal symmetry.</p> <p>Given eight tiles it is possible to form a lamina in only one way: $3 \times 3$ square with a $1 \times 1$ hole in the middle. However, using thirty-two tiles it is possibl...
https://projecteuler.net/problem=174
209566
175
Define $f(0)=1$ and $f(n)$ to be the number of ways to write $n$ as a sum of powers of $2$ where no power occurs more than twice. For example, $f(10)=5$ since there are five different ways to express $10$: $10 = 8+2 = 8+1+1 = 4+4+2 = 4+2+2+1+1 = 4+4+1+1.$ It can be shown that for every fraction $p / q$ ($p \gt 0$, $q...
<p>Define $f(0)=1$ and $f(n)$ to be the number of ways to write $n$ as a sum of powers of $2$ where no power occurs more than twice.</p> <p> For example, $f(10)=5$ since there are five different ways to express $10$:<br>$10 = 8+2 = 8+1+1 = 4+4+2 = 4+2+2+1+1 = 4+4+1+1.$</p> <p> It can be shown that for every fraction ...
https://projecteuler.net/problem=175
1,13717420,8
176
The four right-angled triangles with sides $(9,12,15)$, $(12,16,20)$, $(5,12,13)$ and $(12,35,37)$ all have one of the shorter sides (catheti) equal to $12$. It can be shown that no other integer sided right-angled triangle exists with one of the catheti equal to $12$. Find the smallest integer that can be the length ...
<p>The four right-angled triangles with sides $(9,12,15)$, $(12,16,20)$, $(5,12,13)$ and $(12,35,37)$ all have one of the shorter sides (catheti) equal to $12$. It can be shown that no other integer sided right-angled triangle exists with one of the catheti equal to $12$.</p> <p>Find the smallest integer that can be th...
https://projecteuler.net/problem=176
96818198400000
177
Let $ABCD$ be a convex quadrilateral, with diagonals $AC$ and $BD$. At each vertex the diagonal makes an angle with each of the two sides, creating eight corner angles. For example, at vertex $A$, the two angles are $CAD$, $CAB$. We call such a quadrilateral for which all eight corner angles have integer values when ...
<p>Let $ABCD$ be a convex quadrilateral, with diagonals $AC$ and $BD$. At each vertex the diagonal makes an angle with each of the two sides, creating eight corner angles.</p> <p style="text-align:center;"><img src="resources/images/0177_quad.gif?1678992055" class="dark_img" alt=""></p> <p>For example, at vertex $A$, t...
https://projecteuler.net/problem=177
129325
178
Consider the number $45656$. It can be seen that each pair of consecutive digits of $45656$ has a difference of one. A number for which every pair of consecutive digits has a difference of one is called a step number. A pandigital number contains every decimal digit from $0$ to $9$ at least once. How many pandigit...
Consider the number $45656$. <br> It can be seen that each pair of consecutive digits of $45656$ has a difference of one.<br> A number for which every pair of consecutive digits has a difference of one is called a step number.<br> A pandigital number contains every decimal digit from $0$ to $9$ at least once.<br> How...
https://projecteuler.net/problem=178
126461847755
179
Find the number of integers $1 \lt n \lt 10^7$, for which $n$ and $n + 1$ have the same number of positive divisors. For example, $14$ has the positive divisors $1, 2, 7, 14$ while $15$ has $1, 3, 5, 15$.
<p>Find the number of integers $1 \lt n \lt 10^7$, for which $n$ and $n + 1$ have the same number of positive divisors. For example, $14$ has the positive divisors $1, 2, 7, 14$ while $15$ has $1, 3, 5, 15$.</p>
https://projecteuler.net/problem=179
986262
180
For any integer $n$, consider the three functions $$\begin{align} f_{1, n}(x, y, z) &= x^{n + 1} + y^{n + 1} - z^{n + 1}\\ f_{2, n}(x, y, z) &= (xy + yz + zx) \cdot (x^{n - 1} + y^{n - 1} - z^{n - 1})\\ f_{3, n}(x, y, z) &= xyz \cdot (x^{n - 2} + y^{n - 2} - z^{n - 2}) \end{align}$$ and their combination $$f_n(x, y, ...
<p>For any integer $n$, consider the three functions</p> $$\begin{align} f_{1, n}(x, y, z) &amp;= x^{n + 1} + y^{n + 1} - z^{n + 1}\\ f_{2, n}(x, y, z) &amp;= (xy + yz + zx) \cdot (x^{n - 1} + y^{n - 1} - z^{n - 1})\\ f_{3, n}(x, y, z) &amp;= xyz \cdot (x^{n - 2} + y^{n - 2} - z^{n - 2}) \end{align}$$ <p>and their com...
https://projecteuler.net/problem=180
285196020571078987
181
Having three black objects B and one white object W they can be grouped in 7 ways like this: | (BBBW) | (B,BBW) | (B,B,BW) | (B,B,B,W) | (B,BB,W) | (BBB,W) | (BB,BW) | In how many ways can sixty black objects B and forty white objects W be thus grouped?
<p>Having three black objects B and one white object W they can be grouped in 7 ways like this:</p> <table cellpadding="10" align="center"><tr><td>(BBBW)</td><td>(B,BBW)</td><td>(B,B,BW)</td><td>(B,B,B,W)</td> <td>(B,BB,W)</td><td>(BBB,W)</td><td>(BB,BW)</td> </tr></table><p>In how many ways can sixty black objects B a...
https://projecteuler.net/problem=181
83735848679360680
182
The RSA encryption is based on the following procedure: Generate two distinct primes $p$ and $q$. Compute $n = pq$ and $\phi = (p - 1)(q - 1)$. Find an integer $e$, $1 \lt e \lt \phi$, such that $\gcd(e, \phi) = 1$. A message in this system is a number in the interval $[0, n - 1]$. A text to be encrypted is then so...
<p>The RSA encryption is based on the following procedure:</p> <p>Generate two distinct primes $p$ and $q$.<br>Compute $n = pq$ and $\phi = (p - 1)(q - 1)$.<br> Find an integer $e$, $1 \lt e \lt \phi$, such that $\gcd(e, \phi) = 1$.</p> <p>A message in this system is a number in the interval $[0, n - 1]$.<br> A text to...
https://projecteuler.net/problem=182
399788195976
183
Let $N$ be a positive integer and let $N$ be split into $k$ equal parts, $r = N/k$, so that $N = r + r + \cdots + r$. Let $P$ be the product of these parts, $P = r \times r \times \cdots \times r = r^k$. For example, if $11$ is split into five equal parts, $11 = 2.2 + 2.2 + 2.2 + 2.2 + 2.2$, then $P = 2.2^5 = 51.5363...
<p>Let $N$ be a positive integer and let $N$ be split into $k$ equal parts, $r = N/k$, so that $N = r + r + \cdots + r$.<br> Let $P$ be the product of these parts, $P = r \times r \times \cdots \times r = r^k$.</p> <p>For example, if $11$ is split into five equal parts, $11 = 2.2 + 2.2 + 2.2 + 2.2 + 2.2$, then $P = 2....
https://projecteuler.net/problem=183
48861552
184
Consider the set $I_r$ of points $(x,y)$ with integer co-ordinates in the interior of the circle with radius $r$, centered at the origin, i.e. $x^2 + y^2 \lt r^2$. For a radius of $2$, $I_2$ contains the nine points $(0,0)$, $(1,0)$, $(1,1)$, $(0,1)$, $(-1,1)$, $(-1,0)$, $(-1,-1)$, $(0,-1)$ and $(1,-1)$. There are eig...
<p>Consider the set $I_r$ of points $(x,y)$ with integer co-ordinates in the interior of the circle with radius $r$, centered at the origin, i.e. $x^2 + y^2 \lt r^2$.</p> <p>For a radius of $2$, $I_2$ contains the nine points $(0,0)$, $(1,0)$, $(1,1)$, $(0,1)$, $(-1,1)$, $(-1,0)$, $(-1,-1)$, $(0,-1)$ and $(1,-1)$. Ther...
https://projecteuler.net/problem=184
1725323624056
185
The game Number Mind is a variant of the well known game Master Mind. Instead of coloured pegs, you have to guess a secret sequence of digits. After each guess you're only told in how many places you've guessed the correct digit. So, if the sequence was 1234 and you guessed 2036, you'd be told that you have one correc...
<p>The game Number Mind is a variant of the well known game Master Mind.</p> <p>Instead of coloured pegs, you have to guess a secret sequence of digits. After each guess you're only told in how many places you've guessed the correct digit. So, if the sequence was 1234 and you guessed 2036, you'd be told that you have o...
https://projecteuler.net/problem=185
4640261571849533
186
Here are the records from a busy telephone system with one million users: | RecNr | Caller | Called | | --- | --- | --- | | $1$ | $200007$ | $100053$ | | $2$ | $600183$ | $500439$ | | $3$ | $600863$ | $701497$ | | $\cdots$ | $\cdots$ | $\cdots$ | The telephone number of the caller and the called number in record $n$ ...
<p>Here are the records from a busy telephone system with one million users:</p> <div class="center"> <table class="grid" style="margin:0 auto;"><tr><th>RecNr</th><th width="60" align="center">Caller</th><th width="60" align="center">Called</th></tr> <tr><td align="center">$1$</td><td align="center">$200007$</td><td al...
https://projecteuler.net/problem=186
2325629
187
A composite is a number containing at least two prime factors. For example, $15 = 3 \times 5$; $9 = 3 \times 3$; $12 = 2 \times 2 \times 3$. There are ten composites below thirty containing precisely two, not necessarily distinct, prime factors: $4, 6, 9, 10, 14, 15, 21, 22, 25, 26$. How many composite integers, $n \...
<p>A composite is a number containing at least two prime factors. For example, $15 = 3 \times 5$; $9 = 3 \times 3$; $12 = 2 \times 2 \times 3$.</p> <p>There are ten composites below thirty containing precisely two, not necessarily distinct, prime factors: $4, 6, 9, 10, 14, 15, 21, 22, 25, 26$.</p> <p>How many composi...
https://projecteuler.net/problem=187
17427258
188
The hyperexponentiation or tetration of a number $a$ by a positive integer $b$, denoted by $a\mathbin{\uparrow \uparrow}b$ or $^b a$, is recursively defined by: $a \mathbin{\uparrow \uparrow} 1 = a$, $a \mathbin{\uparrow \uparrow} (k+1) = a^{(a \mathbin{\uparrow \uparrow} k)}$. Thus we have e.g. $3 \mathbin{\uparrow...
<p>The <strong>hyperexponentiation</strong> or <strong>tetration</strong> of a number $a$ by a positive integer $b$, denoted by $a\mathbin{\uparrow \uparrow}b$ or $^b a$, is recursively defined by:<br><br> $a \mathbin{\uparrow \uparrow} 1 = a$,<br> $a \mathbin{\uparrow \uparrow} (k+1) = a^{(a \mathbin{\uparrow \uparrow...
https://projecteuler.net/problem=188
95962097
189
Consider the following configuration of $64$ triangles: We wish to colour the interior of each triangle with one of three colours: red, green or blue, so that no two neighbouring triangles have the same colour. Such a colouring shall be called valid. Here, two triangles are said to be neighbouring if they share an edg...
<p>Consider the following configuration of $64$ triangles:</p> <div class="center"><img src="resources/images/0189_grid.gif?1678992055" class="dark_img" alt=""></div> <p>We wish to colour the interior of each triangle with one of three colours: red, green or blue, so that no two neighbouring triangles have the same c...
https://projecteuler.net/problem=189
10834893628237824
190
Let $S_m = (x_1, x_2, \dots , x_m)$ be the $m$-tuple of positive real numbers with $x_1 + x_2 + \cdots + x_m = m$ for which $P_m = x_1 \cdot x_2^2 \cdot \cdots \cdot x_m^m$ is maximised. For example, it can be verified that $\lfloor P_{10}\rfloor = 4112$ ($\lfloor \, \rfloor$ is the integer part function). Find $\sum...
<p>Let $S_m = (x_1, x_2, \dots , x_m)$ be the $m$-tuple of positive real numbers with $x_1 + x_2 + \cdots + x_m = m$ for which $P_m = x_1 \cdot x_2^2 \cdot \cdots \cdot x_m^m$ is maximised.</p> <p>For example, it can be verified that $\lfloor P_{10}\rfloor = 4112$ ($\lfloor \, \rfloor$ is the integer part function).</...
https://projecteuler.net/problem=190
371048281
191
A particular school offers cash rewards to children with good attendance and punctuality. If they are absent for three consecutive days or late on more than one occasion then they forfeit their prize. During an n-day period a trinary string is formed for each child consisting of L's (late), O's (on time), and A's (abs...
<p>A particular school offers cash rewards to children with good attendance and punctuality. If they are absent for three consecutive days or late on more than one occasion then they forfeit their prize.</p> <p>During an n-day period a trinary string is formed for each child consisting of L's (late), O's (on time), an...
https://projecteuler.net/problem=191
1918080160
192
Let $x$ be a real number. A best approximation to $x$ for the denominator bound $d$ is a rational number $\frac r s $ in reduced form, with $s \le d$, such that any rational number which is closer to $x$ than $\frac r s$ has a denominator larger than $d$: $|\frac p q -x | < |\frac r s -x| \Rightarrow q > d$ For exa...
<p>Let $x$ be a real number.<br> A <b>best approximation</b> to $x$ for the <b>denominator bound</b> $d$ is a rational number $\frac r s $ in<b> reduced form</b>, with $s \le d$, such that any rational number which is closer to $x$ than $\frac r s$ has a denominator larger than $d$:</p> <div class="center"> $|\frac p...
https://projecteuler.net/problem=192
57060635927998347
193
A positive integer $n$ is called squarefree, if no square of a prime divides $n$, thus $1, 2, 3, 5, 6, 7, 10, 11$ are squarefree, but not $4, 8, 9, 12$. How many squarefree numbers are there below $2^{50}$?
<p>A positive integer $n$ is called squarefree, if no square of a prime divides $n$, thus $1, 2, 3, 5, 6, 7, 10, 11$ are squarefree, but not $4, 8, 9, 12$.</p> <p>How many squarefree numbers are there below $2^{50}$?</p>
https://projecteuler.net/problem=193
684465067343069
194
Consider graphs built with the units $A$: and $B$: , where the units are glued along the vertical edges as in the graph . A configuration of type $(a, b, c)$ is a graph thus built of $a$ units $A$ and $b$ units $B$, where the graph's vertices are coloured using up to $c$ colours, so that no two adjacent vertices have ...
<p>Consider graphs built with the units $A$: <img src="resources/images/0194_GraphA.png?1678992052" style="vertical-align:middle;" class="dark_img" alt=""> and $B$: <img src="resources/images/0194_GraphB.png?1678992052" style="vertical-align:middle;" class="dark_img" alt="">, where the units are glued along the vertica...
https://projecteuler.net/problem=194
61190912
195
Let's call an integer sided triangle with exactly one angle of $60$ degrees a $60$-degree triangle. Let $r$ be the radius of the inscribed circle of such a $60$-degree triangle. There are $1234$ $60$-degree triangles for which $r \le 100$. Let $T(n)$ be the number of $60$-degree triangles for which $r \le n$, so $T...
<p>Let's call an integer sided triangle with exactly one angle of $60$ degrees a $60$-degree triangle.<br> Let $r$ be the radius of the inscribed circle of such a $60$-degree triangle.</p> <p>There are $1234$ $60$-degree triangles for which $r \le 100$. <br>Let $T(n)$ be the number of $60$-degree triangles for which $r...
https://projecteuler.net/problem=195
75085391
196
Build a triangle from all positive integers in the following way: 1 2  3 4  5  6 7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 . . . Each positive integer has up to eight neighb...
<p>Build a triangle from all positive integers in the following way:</p> <p style="font-family:'courier new', monospace;font-weight:bold;margin-left:50px;"> 1<br>  <span style="color:#FF0000;">2</span>  <span style="color:#FF0000;">3</span><br>  4  <span style="color:#FF0000;">5</span>  6<br>  <span style="color:#FF00...
https://projecteuler.net/problem=196
322303240771079935
197
Given is the function $f(x) = \lfloor 2^{30.403243784 - x^2}\rfloor \times 10^{-9}$ ($\lfloor \, \rfloor$ is the floor-function), the sequence $u_n$ is defined by $u_0 = -1$ and $u_{n + 1} = f(u_n)$. Find $u_n + u_{n + 1}$ for $n = 10^{12}$. Give your answer with $9$ digits after the decimal point.
<p>Given is the function $f(x) = \lfloor 2^{30.403243784 - x^2}\rfloor \times 10^{-9}$ ($\lfloor \, \rfloor$ is the floor-function),<br> the sequence $u_n$ is defined by $u_0 = -1$ and $u_{n + 1} = f(u_n)$.</p> <p>Find $u_n + u_{n + 1}$ for $n = 10^{12}$.<br> Give your answer with $9$ digits after the decimal point.</...
https://projecteuler.net/problem=197
1.710637717
198
A best approximation to a real number $x$ for the denominator bound $d$ is a rational number $\frac r s$ (in reduced form) with $s \le d$, so that any rational number $\frac p q$ which is closer to $x$ than $\frac r s$ has $q \gt d$. Usually the best approximation to a real number is uniquely determined for all denomi...
<p>A best approximation to a real number $x$ for the denominator bound $d$ is a rational number $\frac r s$ (in reduced form) with $s \le d$, so that any rational number $\frac p q$ which is closer to $x$ than $\frac r s$ has $q \gt d$.</p> <p>Usually the best approximation to a real number is uniquely determined for ...
https://projecteuler.net/problem=198
52374425
199
Three circles of equal radius are placed inside a larger circle such that each pair of circles is tangent to one another and the inner circles do not overlap. There are four uncovered "gaps" which are to be filled iteratively with more tangent circles. At each iteration, a maximally sized circle is placed in each gap,...
<p>Three circles of equal radius are placed inside a larger circle such that each pair of circles is tangent to one another and the inner circles do not overlap. There are four uncovered "gaps" which are to be filled iteratively with more tangent circles.</p> <div class="center"> <img src="resources/images/0199_circles...
https://projecteuler.net/problem=199
0.00396087
200
We shall define a sqube to be a number of the form, $p^2 q^3$, where $p$ and $q$ are distinct primes. For example, $200 = 5^2 2^3$ or $120072949 = 23^2 61^3$. The first five squbes are $72, 108, 200, 392$, and $500$. Interestingly, $200$ is also the first number for which you cannot change any single digit to make a...
<p>We shall define a sqube to be a number of the form, $p^2 q^3$, where $p$ and $q$ are distinct primes.<br> For example, $200 = 5^2 2^3$ or $120072949 = 23^2 61^3$.</p> <p>The first five squbes are $72, 108, 200, 392$, and $500$.</p> <p>Interestingly, $200$ is also the first number for which you cannot change any si...
https://projecteuler.net/problem=200
229161792008