id
int64
1
981
problem
stringlengths
97
5.29k
raw_html
stringlengths
121
5.63k
url
stringlengths
34
36
answer
stringlengths
1
29
201
For any set $A$ of numbers, let $\operatorname{sum}(A)$ be the sum of the elements of $A$. Consider the set $B = \{1,3,6,8,10,11\}$. There are $20$ subsets of $B$ containing three elements, and their sums are: $$\begin{align} \operatorname{sum}(\{1,3,6\}) &= 10,\\ \operatorname{sum}(\{1,3,8\}) &= 12,\\ \operatorname{sum}(\{1,3,10\}) &= 14,\\ \operatorname{sum}(\{1,3,11\}) &= 15,\\ \operatorname{sum}(\{1,6,8\}) &= 15,\\ \operatorname{sum}(\{1,6,10\}) &= 17,\\ \operatorname{sum}(\{1,6,11\}) &= 18,\\ \operatorname{sum}(\{1,8,10\}) &= 19,\\ \operatorname{sum}(\{1,8,11\}) &= 20,\\ \operatorname{sum}(\{1,10,11\}) &= 22,\\ \operatorname{sum}(\{3,6,8\}) &= 17,\\ \operatorname{sum}(\{3,6,10\}) &= 19,\\ \operatorname{sum}(\{3,6,11\}) &= 20,\\ \operatorname{sum}(\{3,8,10\}) &= 21,\\ \operatorname{sum}(\{3,8,11\}) &= 22,\\ \operatorname{sum}(\{3,10,11\}) &= 24,\\ \operatorname{sum}(\{6,8,10\}) &= 24,\\ \operatorname{sum}(\{6,8,11\}) &= 25,\\ \operatorname{sum}(\{6,10,11\}) &= 27,\\ \operatorname{sum}(\{8,10,11\}) &= 29. \end{align}$$ Some of these sums occur more than once, others are unique. For a set $A$, let $U(A,k)$ be the set of unique sums of $k$-element subsets of $A$, in our example we find $U(B,3) = \{10,12,14,18,21,25,27,29\}$ and $\operatorname{sum}(U(B,3)) = 156$. Now consider the $100$-element set $S = \{1^2, 2^2, \dots, 100^2\}$. S has $100891344545564193334812497256$ $50$-element subsets. Determine the sum of all integers which are the sum of exactly one of the $50$-element subsets of $S$, i.e. find $\operatorname{sum}(U(S,50))$.
<p>For any set $A$ of numbers, let $\operatorname{sum}(A)$ be the sum of the elements of $A$.<br> Consider the set $B = \{1,3,6,8,10,11\}$.<br> There are $20$ subsets of $B$ containing three elements, and their sums are:</p> $$\begin{align} \operatorname{sum}(\{1,3,6\}) &amp;= 10,\\ \operatorname{sum}(\{1,3,8\}) &amp;= 12,\\ \operatorname{sum}(\{1,3,10\}) &amp;= 14,\\ \operatorname{sum}(\{1,3,11\}) &amp;= 15,\\ \operatorname{sum}(\{1,6,8\}) &amp;= 15,\\ \operatorname{sum}(\{1,6,10\}) &amp;= 17,\\ \operatorname{sum}(\{1,6,11\}) &amp;= 18,\\ \operatorname{sum}(\{1,8,10\}) &amp;= 19,\\ \operatorname{sum}(\{1,8,11\}) &amp;= 20,\\ \operatorname{sum}(\{1,10,11\}) &amp;= 22,\\ \operatorname{sum}(\{3,6,8\}) &amp;= 17,\\ \operatorname{sum}(\{3,6,10\}) &amp;= 19,\\ \operatorname{sum}(\{3,6,11\}) &amp;= 20,\\ \operatorname{sum}(\{3,8,10\}) &amp;= 21,\\ \operatorname{sum}(\{3,8,11\}) &amp;= 22,\\ \operatorname{sum}(\{3,10,11\}) &amp;= 24,\\ \operatorname{sum}(\{6,8,10\}) &amp;= 24,\\ \operatorname{sum}(\{6,8,11\}) &amp;= 25,\\ \operatorname{sum}(\{6,10,11\}) &amp;= 27,\\ \operatorname{sum}(\{8,10,11\}) &amp;= 29. \end{align}$$ <p>Some of these sums occur more than once, others are unique.<br> For a set $A$, let $U(A,k)$ be the set of unique sums of $k$-element subsets of $A$, in our example we find $U(B,3) = \{10,12,14,18,21,25,27,29\}$ and $\operatorname{sum}(U(B,3)) = 156$.</p> <p>Now consider the $100$-element set $S = \{1^2, 2^2, \dots, 100^2\}$.<br> S has $100891344545564193334812497256$ $50$-element subsets.</p> <p>Determine the sum of all integers which are the sum of exactly one of the $50$-element subsets of $S$, i.e. find $\operatorname{sum}(U(S,50))$.</p>
https://projecteuler.net/problem=201
115039000
202
Three mirrors are arranged in the shape of an equilateral triangle, with their reflective surfaces pointing inwards. There is an infinitesimal gap at each vertex of the triangle through which a laser beam may pass. Label the vertices $A$, $B$ and $C$. There are $2$ ways in which a laser beam may enter vertex $C$, bounce off $11$ surfaces, then exit through the same vertex: one way is shown below; the other is the reverse of that. There are $80840$ ways in which a laser beam may enter vertex $C$, bounce off $1000001$ surfaces, then exit through the same vertex. In how many ways can a laser beam enter at vertex $C$, bounce off $12017639147$ surfaces, then exit through the same vertex?
<p>Three mirrors are arranged in the shape of an equilateral triangle, with their reflective surfaces pointing inwards. There is an infinitesimal gap at each vertex of the triangle through which a laser beam may pass.</p> <p>Label the vertices $A$, $B$ and $C$. There are $2$ ways in which a laser beam may enter vertex $C$, bounce off $11$ surfaces, then exit through the same vertex: one way is shown below; the other is the reverse of that.</p> <div class="center"> <img src="resources/images/0202_laserbeam.gif?1678992055" class="dark_img" alt=""></div> <p>There are $80840$ ways in which a laser beam may enter vertex $C$, bounce off $1000001$ surfaces, then exit through the same vertex.</p> <p>In how many ways can a laser beam enter at vertex $C$, bounce off $12017639147$ surfaces, then exit through the same vertex?</p>
https://projecteuler.net/problem=202
1209002624
203
The binomial coefficients $\displaystyle \binom n k$ can be arranged in triangular form, Pascal's triangle, like this: | | 1 | | | | 1 | | 1 | | | | 1 | | 2 | | 1 | | | | 1 | | 3 | | 3 | | 1 | | | | 1 | | 4 | | 6 | | 4 | | 1 | | | | 1 | | 5 | | 10 | | 10 | | 5 | | 1 | | | | 1 | | 6 | | 15 | | 20 | | 15 | | 6 | | 1 | | | 1 | | 7 | | 21 | | 35 | | 35 | | 21 | | 7 | | 1 | ......... It can be seen that the first eight rows of Pascal's triangle contain twelve distinct numbers: 1, 2, 3, 4, 5, 6, 7, 10, 15, 20, 21 and 35. A positive integer n is called squarefree if no square of a prime divides n. Of the twelve distinct numbers in the first eight rows of Pascal's triangle, all except 4 and 20 are squarefree. The sum of the distinct squarefree numbers in the first eight rows is 105. Find the sum of the distinct squarefree numbers in the first 51 rows of Pascal's triangle.
<p>The binomial coefficients $\displaystyle \binom n k$ can be arranged in triangular form, Pascal's triangle, like this:</p> <div class="center"> <table align="center"><tr><td colspan="7"></td><td>1</td><td colspan="7"></td></tr><tr><td colspan="6"></td><td>1</td><td></td><td>1</td><td colspan="6"></td></tr><tr><td colspan="5"></td><td>1</td><td></td><td>2</td><td></td><td>1</td><td colspan="5"></td></tr><tr><td colspan="4"></td><td>1</td><td></td><td>3</td><td></td><td>3</td><td></td><td>1</td><td colspan="4"></td></tr><tr><td colspan="3"></td><td>1</td><td></td><td>4</td><td></td><td>6</td><td></td><td>4</td><td></td><td>1</td><td colspan="3"></td></tr><tr><td colspan="2"></td><td>1</td><td></td><td>5</td><td></td><td>10</td><td></td><td>10</td><td></td><td>5</td><td></td><td>1</td><td colspan="2"></td></tr><tr><td colspan="1"></td><td>1</td><td></td><td>6</td><td></td><td>15</td><td></td><td>20</td><td></td><td>15</td><td></td><td>6</td><td></td><td>1</td><td colspan="1"></td></tr><tr><td>1</td><td></td><td>7</td><td></td><td>21</td><td></td><td>35</td><td></td><td>35</td><td></td><td>21</td><td></td><td>7</td><td></td><td>1</td></tr></table> ......... </div> <p>It can be seen that the first eight rows of Pascal's triangle contain twelve distinct numbers: 1, 2, 3, 4, 5, 6, 7, 10, 15, 20, 21 and 35.</p> <p>A positive integer <var>n</var> is called squarefree if no square of a prime divides <var>n</var>. Of the twelve distinct numbers in the first eight rows of Pascal's triangle, all except 4 and 20 are squarefree. The sum of the distinct squarefree numbers in the first eight rows is 105.</p> <p>Find the sum of the distinct squarefree numbers in the first 51 rows of Pascal's triangle.</p>
https://projecteuler.net/problem=203
34029210557338
204
A Hamming number is a positive number which has no prime factor larger than $5$. So the first few Hamming numbers are $1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15$. There are $1105$ Hamming numbers not exceeding $10^8$. We will call a positive number a generalised Hamming number of type $n$, if it has no prime factor larger than $n$. Hence the Hamming numbers are the generalised Hamming numbers of type $5$. How many generalised Hamming numbers of type $100$ are there which don't exceed $10^9$?
<p>A Hamming number is a positive number which has no prime factor larger than $5$.<br> So the first few Hamming numbers are $1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15$.<br> There are $1105$ Hamming numbers not exceeding $10^8$.</p> <p>We will call a positive number a generalised Hamming number of type $n$, if it has no prime factor larger than $n$.<br> Hence the Hamming numbers are the generalised Hamming numbers of type $5$.</p> <p>How many generalised Hamming numbers of type $100$ are there which don't exceed $10^9$?</p>
https://projecteuler.net/problem=204
2944730
205
Peter has nine four-sided (pyramidal) dice, each with faces numbered $1, 2, 3, 4$. Colin has six six-sided (cubic) dice, each with faces numbered $1, 2, 3, 4, 5, 6$. Peter and Colin roll their dice and compare totals: the highest total wins. The result is a draw if the totals are equal. What is the probability that Pyramidal Peter beats Cubic Colin? Give your answer rounded to seven decimal places in the form 0.abcdefg.
<p>Peter has nine four-sided (pyramidal) dice, each with faces numbered $1, 2, 3, 4$.<br> Colin has six six-sided (cubic) dice, each with faces numbered $1, 2, 3, 4, 5, 6$.</p> <p>Peter and Colin roll their dice and compare totals: the highest total wins. The result is a draw if the totals are equal.</p> <p>What is the probability that Pyramidal Peter beats Cubic Colin? Give your answer rounded to seven decimal places in the form 0.abcdefg.</p>
https://projecteuler.net/problem=205
0.5731441
206
Find the unique positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0, where each “_” is a single digit.
<p>Find the unique positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0,<br> where each “_” is a single digit.</p>
https://projecteuler.net/problem=206
1389019170
207
For some positive integers $k$, there exists an integer partition of the form $4^t = 2^t + k$, where $4^t$, $2^t$, and $k$ are all positive integers and $t$ is a real number. The first two such partitions are $4^1 = 2^1 + 2$ and $4^{1.5849625\cdots} = 2^{1.5849625\cdots} + 6$. Partitions where $t$ is also an integer are called perfect. For any $m \ge 1$ let $P(m)$ be the proportion of such partitions that are perfect with $k \le m$. Thus $P(6) = 1/2$. In the following table are listed some values of $P(m)$. $$\begin{align} P(5) &= 1/1\\ P(10) &= 1/2\\ P(15) &= 2/3\\ P(20) &= 1/2\\ P(25) &= 1/2\\ P(30) &= 2/5\\ \cdots &\\ P(180) &= 1/4\\ P(185) &= 3/13 \end{align}$$ Find the smallest $m$ for which $P(m) \lt 1/12345$.
<p>For some positive integers $k$, there exists an integer partition of the form $4^t = 2^t + k$,<br> where $4^t$, $2^t$, and $k$ are all positive integers and $t$ is a real number.</p> <p>The first two such partitions are $4^1 = 2^1 + 2$ and $4^{1.5849625\cdots} = 2^{1.5849625\cdots} + 6$.</p> <p>Partitions where $t$ is also an integer are called <dfn>perfect</dfn>.<br> For any $m \ge 1$ let $P(m)$ be the proportion of such partitions that are perfect with $k \le m$.<br> Thus $P(6) = 1/2$.</p> <p>In the following table are listed some values of $P(m)$.</p> $$\begin{align} P(5) &amp;= 1/1\\ P(10) &amp;= 1/2\\ P(15) &amp;= 2/3\\ P(20) &amp;= 1/2\\ P(25) &amp;= 1/2\\ P(30) &amp;= 2/5\\ \cdots &amp;\\ P(180) &amp;= 1/4\\ P(185) &amp;= 3/13 \end{align}$$ <p>Find the smallest $m$ for which $P(m) \lt 1/12345$.</p>
https://projecteuler.net/problem=207
44043947822
208
A robot moves in a series of one-fifth circular arcs ($72^\circ$), with a free choice of a clockwise or an anticlockwise arc for each step, but no turning on the spot. One of $70932$ possible closed paths of $25$ arcs starting northward is Given that the robot starts facing North, how many journeys of $70$ arcs in length can it take that return it, after the final arc, to its starting position? (Any arc may be traversed multiple times.)
<p>A robot moves in a series of one-fifth circular arcs ($72^\circ$), with a free choice of a clockwise or an anticlockwise arc for each step, but no turning on the spot.</p> <p>One of $70932$ possible closed paths of $25$ arcs starting northward is</p> <div class="center"> <img src="resources/images/0208_robotwalk.gif?1678992055" class="dark_img" alt=""></div> <p>Given that the robot starts facing North, how many journeys of $70$ arcs in length can it take that return it, after the final arc, to its starting position?<br> (Any arc may be traversed multiple times.) </p>
https://projecteuler.net/problem=208
331951449665644800
209
A $k$-input binary truth table is a map from $k$ input bits (binary digits, $0$ [false] or $1$ [true]) to $1$ output bit. For example, the $2$-input binary truth tables for the logical $\mathbin{\text{AND}}$ and $\mathbin{\text{XOR}}$ functions are: | $x$ | $y$ | $x \mathbin{\text{AND}} y$ | | --- | --- | --- | | $0$ | $0$ | $0$ | | $0$ | $1$ | $0$ | | $1$ | $0$ | $0$ | | $1$ | $1$ | $1$ | | $x$ | $y$ | $x\mathbin{\text{XOR}}y$ | | --- | --- | --- | | $0$ | $0$ | $0$ | | $0$ | $1$ | $1$ | | $1$ | $0$ | $1$ | | $1$ | $1$ | $0$ | How many $6$-input binary truth tables, $\tau$, satisfy the formula $$\tau(a, b, c, d, e, f) \mathbin{\text{AND}} \tau(b, c, d, e, f, a \mathbin{\text{XOR}} (b \mathbin{\text{AND}} c)) = 0$$ for all $6$-bit inputs $(a, b, c, d, e, f)$?
<p>A $k$-input <strong>binary truth table</strong> is a map from $k$ input bits (binary digits, $0$ [false] or $1$ [true]) to $1$ output bit. For example, the $2$-input binary truth tables for the logical $\mathbin{\text{AND}}$ and $\mathbin{\text{XOR}}$ functions are:</p> <div style="float:left;margin:10px 50px;text-align:center;"> <table class="grid"><tr><th style="width:50px;">$x$</th> <th style="width:50px;">$y$</th> <th>$x \mathbin{\text{AND}} y$</th></tr> <tr><td align="center">$0$</td><td align="center">$0$</td><td align="center">$0$</td></tr><tr><td align="center">$0$</td><td align="center">$1$</td><td align="center">$0$</td></tr><tr><td align="center">$1$</td><td align="center">$0$</td><td align="center">$0$</td></tr><tr><td align="center">$1$</td><td align="center">$1$</td><td align="center">$1$</td></tr></table> </div> <div style="float:left;margin:10px 50px;text-align:center;"> <table class="grid"><tr><th style="width:50px;">$x$</th> <th style="width:50px;">$y$</th> <th>$x\mathbin{\text{XOR}}y$</th></tr> <tr><td align="center">$0$</td><td align="center">$0$</td><td align="center">$0$</td></tr><tr><td align="center">$0$</td><td align="center">$1$</td><td align="center">$1$</td></tr><tr><td align="center">$1$</td><td align="center">$0$</td><td align="center">$1$</td></tr><tr><td align="center">$1$</td><td align="center">$1$</td><td align="center">$0$</td></tr></table> </div> <br clear="all"> <p>How many $6$-input binary truth tables, $\tau$, satisfy the formula $$\tau(a, b, c, d, e, f) \mathbin{\text{AND}} \tau(b, c, d, e, f, a \mathbin{\text{XOR}} (b \mathbin{\text{AND}} c)) = 0$$ for all $6$-bit inputs $(a, b, c, d, e, f)$? </p>
https://projecteuler.net/problem=209
15964587728784
210
Consider the set $S(r)$ of points $(x,y)$ with integer coordinates satisfying $|x| + |y| \le r$. Let $O$ be the point $(0,0)$ and $C$ the point $(r/4,r/4)$. Let $N(r)$ be the number of points $B$ in $S(r)$, so that the triangle $OBC$ has an obtuse angle, i.e. the largest angle $\alpha$ satisfies $90^\circ \lt \alpha \lt 180^\circ$. So, for example, $N(4)=24$ and $N(8)=100$. What is $N(1\,000\,000\,000)$?
Consider the set $S(r)$ of points $(x,y)$ with integer coordinates satisfying $|x| + |y| \le r$.<br> Let $O$ be the point $(0,0)$ and $C$ the point $(r/4,r/4)$. <br> Let $N(r)$ be the number of points $B$ in $S(r)$, so that the triangle $OBC$ has an obtuse angle, i.e. the largest angle $\alpha$ satisfies $90^\circ \lt \alpha \lt 180^\circ$.<br> So, for example, $N(4)=24$ and $N(8)=100$. <p> What is $N(1\,000\,000\,000)$? </p>
https://projecteuler.net/problem=210
1598174770174689458
211
For a positive integer $n$, let $\sigma_2(n)$ be the sum of the squares of its divisors. For example, $$\sigma_2(10) = 1 + 4 + 25 + 100 = 130.$$ Find the sum of all $n$, $0 \lt n \lt 64\,000\,000$ such that $\sigma_2(n)$ is a perfect square.
<p>For a positive integer $n$, let $\sigma_2(n)$ be the sum of the squares of its divisors. For example, $$\sigma_2(10) = 1 + 4 + 25 + 100 = 130.$$</p> <p>Find the sum of all $n$, $0 \lt n \lt 64\,000\,000$ such that $\sigma_2(n)$ is a perfect square.</p>
https://projecteuler.net/problem=211
1922364685
212
An axis-aligned cuboid, specified by parameters $\{(x_0, y_0, z_0), (dx, dy, dz)\}$, consists of all points $(X,Y,Z)$ such that $x_0 \le X \le x_0 + dx$, $y_0 \le Y \le y_0 + dy$ and $z_0 \le Z \le z_0 + dz$. The volume of the cuboid is the product, $dx \times dy \times dz$. The combined volume of a collection of cuboids is the volume of their union and will be less than the sum of the individual volumes if any cuboids overlap. Let $C_1, \dots, C_{50000}$ be a collection of $50000$ axis-aligned cuboids such that $C_n$ has parameters $$\begin{align} x_0 &= S_{6n - 5} \bmod 10000\\ y_0 &= S_{6n - 4} \bmod 10000\\ z_0 &= S_{6n - 3} \bmod 10000\\ dx &= 1 + (S_{6n - 2} \bmod 399)\\ dy &= 1 + (S_{6n - 1} \bmod 399)\\ dz &= 1 + (S_{6n} \bmod 399) \end{align}$$ where $S_1,\dots,S_{300000}$ come from the "Lagged Fibonacci Generator": - For $1 \le k \le 55$, $S_k = [100003 - 200003k + 300007k^3] \pmod{1000000}$. - For $56 \le k$, $S_k = [S_{k -24} + S_{k - 55}] \pmod{1000000}$. Thus, $C_1$ has parameters $\{(7,53,183),(94,369,56)\}$, $C_2$ has parameters $\{(2383,3563,5079),(42,212,344)\}$, and so on. The combined volume of the first $100$ cuboids, $C_1, \dots, C_{100}$, is $723581599$. What is the combined volume of all $50000$ cuboids, $C_1, \dots, C_{50000}$?
<p>An <dfn>axis-aligned cuboid</dfn>, specified by parameters $\{(x_0, y_0, z_0), (dx, dy, dz)\}$, consists of all points $(X,Y,Z)$ such that $x_0 \le X \le x_0 + dx$, $y_0 \le Y \le y_0 + dy$ and $z_0 \le Z \le z_0 + dz$. The volume of the cuboid is the product, $dx \times dy \times dz$. The <dfn>combined volume</dfn> of a collection of cuboids is the volume of their union and will be less than the sum of the individual volumes if any cuboids overlap.</p> <p>Let $C_1, \dots, C_{50000}$ be a collection of $50000$ axis-aligned cuboids such that $C_n$ has parameters</p> $$\begin{align} x_0 &amp;= S_{6n - 5} \bmod 10000\\ y_0 &amp;= S_{6n - 4} \bmod 10000\\ z_0 &amp;= S_{6n - 3} \bmod 10000\\ dx &amp;= 1 + (S_{6n - 2} \bmod 399)\\ dy &amp;= 1 + (S_{6n - 1} \bmod 399)\\ dz &amp;= 1 + (S_{6n} \bmod 399) \end{align}$$ <p>where $S_1,\dots,S_{300000}$ come from the "Lagged Fibonacci Generator":</p> <ul style="list-style-type:none;"><li>For $1 \le k \le 55$, $S_k = [100003 - 200003k + 300007k^3] \pmod{1000000}$.</li><li>For $56 \le k$, $S_k = [S_{k -24} + S_{k - 55}] \pmod{1000000}$.</li></ul> <p>Thus, $C_1$ has parameters $\{(7,53,183),(94,369,56)\}$, $C_2$ has parameters $\{(2383,3563,5079),(42,212,344)\}$, and so on.</p> <p>The combined volume of the first $100$ cuboids, $C_1, \dots, C_{100}$, is $723581599$.</p> <p>What is the combined volume of all $50000$ cuboids, $C_1, \dots, C_{50000}$?</p>
https://projecteuler.net/problem=212
328968937309
213
A $30 \times 30$ grid of squares contains $900$ fleas, initially one flea per square. When a bell is rung, each flea jumps to an adjacent square at random (usually $4$ possibilities, except for fleas on the edge of the grid or at the corners). What is the expected number of unoccupied squares after $50$ rings of the bell? Give your answer rounded to six decimal places.
<p>A $30 \times 30$ grid of squares contains $900$ fleas, initially one flea per square.<br> When a bell is rung, each flea jumps to an adjacent square at random (usually $4$ possibilities, except for fleas on the edge of the grid or at the corners).</p> <p>What is the expected number of unoccupied squares after $50$ rings of the bell? Give your answer rounded to six decimal places.</p>
https://projecteuler.net/problem=213
330.721154
214
Let $\phi$ be Euler's totient function, i.e. for a natural number $n$, $\phi(n)$ is the number of $k$, $1 \le k \le n$, for which $\gcd(k, n) = 1$. By iterating $\phi$, each positive integer generates a decreasing chain of numbers ending in $1$. E.g. if we start with $5$ the sequence $5,4,2,1$ is generated. Here is a listing of all chains with length $4$: $$\begin{align} 5,4,2,1&\\ 7,6,2,1&\\ 8,4,2,1&\\ 9,6,2,1&\\ 10,4,2,1&\\ 12,4,2,1&\\ 14,6,2,1&\\ 18,6,2,1 \end{align}$$ Only two of these chains start with a prime, their sum is $12$. What is the sum of all primes less than $40000000$ which generate a chain of length $25$?
<p>Let $\phi$ be Euler's totient function, i.e. for a natural number $n$, $\phi(n)$ is the number of $k$, $1 \le k \le n$, for which $\gcd(k, n) = 1$.</p> <p>By iterating $\phi$, each positive integer generates a decreasing chain of numbers ending in $1$.<br> E.g. if we start with $5$ the sequence $5,4,2,1$ is generated.<br> Here is a listing of all chains with length $4$:</p> $$\begin{align} 5,4,2,1&amp;\\ 7,6,2,1&amp;\\ 8,4,2,1&amp;\\ 9,6,2,1&amp;\\ 10,4,2,1&amp;\\ 12,4,2,1&amp;\\ 14,6,2,1&amp;\\ 18,6,2,1 \end{align}$$ <p>Only two of these chains start with a prime, their sum is $12$.</p> <p>What is the sum of all primes less than $40000000$ which generate a chain of length $25$?</p>
https://projecteuler.net/problem=214
1677366278943
215
Consider the problem of building a wall out of $2 \times 1$ and $3 \times 1$ bricks ($\text{horizontal} \times \text{vertical}$ dimensions) such that, for extra strength, the gaps between horizontally-adjacent bricks never line up in consecutive layers, i.e. never form a "running crack". For example, the following $9 \times 3$ wall is not acceptable due to the running crack shown in red: There are eight ways of forming a crack-free $9 \times 3$ wall, written $W(9,3) = 8$. Calculate $W(32,10)$.
<p>Consider the problem of building a wall out of $2 \times 1$ and $3 \times 1$ bricks ($\text{horizontal} \times \text{vertical}$ dimensions) such that, for extra strength, the gaps between horizontally-adjacent bricks never line up in consecutive layers, i.e. never form a "running crack".</p> <p>For example, the following $9 \times 3$ wall is not acceptable due to the running crack shown in red:</p> <div class="center"> <img src="resources/images/0215_crackfree.gif?1678992055" class="dark_img" alt=""></div> <p>There are eight ways of forming a crack-free $9 \times 3$ wall, written $W(9,3) = 8$.</p> <p>Calculate $W(32,10)$.</p>
https://projecteuler.net/problem=215
806844323190414
216
Consider numbers $t(n)$ of the form $t(n) = 2n^2 - 1$ with $n \gt 1$. The first such numbers are $7, 17, 31, 49, 71, 97, 127$ and $161$. It turns out that only $49 = 7 \cdot 7$ and $161 = 7 \cdot 23$ are not prime. For $n \le 10000$ there are $2202$ numbers $t(n)$ that are prime. How many numbers $t(n)$ are prime for $n \le 50\,000\,000$?
<p>Consider numbers $t(n)$ of the form $t(n) = 2n^2 - 1$ with $n \gt 1$.<br> The first such numbers are $7, 17, 31, 49, 71, 97, 127$ and $161$.<br> It turns out that only $49 = 7 \cdot 7$ and $161 = 7 \cdot 23$ are not prime.<br> For $n \le 10000$ there are $2202$ numbers $t(n)$ that are prime.</p> <p>How many numbers $t(n)$ are prime for $n \le 50\,000\,000$?</p>
https://projecteuler.net/problem=216
5437849
217
A positive integer with $k$ (decimal) digits is called balanced if its first $\lceil k/2 \rceil$ digits sum to the same value as its last $\lceil k/2 \rceil$ digits, where $\lceil x \rceil$, pronounced ceiling of $x$, is the smallest integer $\ge x$, thus $\lceil \pi \rceil = 4$ and $\lceil 5 \rceil = 5$. So, for example, all palindromes are balanced, as is $13722$. Let $T(n)$ be the sum of all balanced numbers less than $10^n$. Thus: $T(1) = 45$, $T(2) = 540$ and $T(5) = 334795890$. Find $T(47) \bmod 3^{15}$.
<p> A positive integer with $k$ (decimal) digits is called balanced if its first $\lceil k/2 \rceil$ digits sum to the same value as its last $\lceil k/2 \rceil$ digits, where $\lceil x \rceil$, pronounced <i>ceiling</i> of $x$, is the smallest integer $\ge x$, thus $\lceil \pi \rceil = 4$ and $\lceil 5 \rceil = 5$.</p> <p>So, for example, all palindromes are balanced, as is $13722$.</p> <p>Let $T(n)$ be the sum of all balanced numbers less than $10^n$. <br> Thus: $T(1) = 45$, $T(2) = 540$ and $T(5) = 334795890$.</p> <p>Find $T(47) \bmod 3^{15}$.</p>
https://projecteuler.net/problem=217
6273134
218
Consider the right angled triangle with sides $a=7$, $b=24$ and $c=25$. The area of this triangle is $84$, which is divisible by the perfect numbers $6$ and $28$. Moreover it is a primitive right angled triangle as $\gcd(a,b)=1$ and $\gcd(b,c)=1$. Also $c$ is a perfect square. We will call a right angled triangle perfect if -it is a primitive right angled triangle -its hypotenuse is a perfect square. We will call a right angled triangle super-perfect if -it is a perfect right angled triangle and -its area is a multiple of the perfect numbers $6$ and $28$. How many perfect right-angled triangles with $c \le 10^{16}$ exist that are not super-perfect?
<p>Consider the right angled triangle with sides $a=7$, $b=24$ and $c=25$. The area of this triangle is $84$, which is divisible by the perfect numbers $6$ and $28$.<br> Moreover it is a primitive right angled triangle as $\gcd(a,b)=1$ and $\gcd(b,c)=1$.<br> Also $c$ is a perfect square.</p> <p>We will call a right angled triangle perfect if<br> -it is a primitive right angled triangle<br> -its hypotenuse is a perfect square.</p> <p>We will call a right angled triangle super-perfect if<br> -it is a perfect right angled triangle and<br> -its area is a multiple of the perfect numbers $6$ and $28$. </p> <p>How many perfect right-angled triangles with $c \le 10^{16}$ exist that are not super-perfect?</p>
https://projecteuler.net/problem=218
0
219
Let A and B be bit strings (sequences of 0's and 1's). If A is equal to the leftmost length(A) bits of B, then A is said to be a prefix of B. For example, 00110 is a prefix of 001101001, but not of 00111 or 100110. A prefix-free code of size n is a collection of n distinct bit strings such that no string is a prefix of any other. For example, this is a prefix-free code of size 6: 0000, 0001, 001, 01, 10, 11 Now suppose that it costs one penny to transmit a '0' bit, but four pence to transmit a '1'. Then the total cost of the prefix-free code shown above is 35 pence, which happens to be the cheapest possible for the skewed pricing scheme in question. In short, we write Cost(6) = 35. What is Cost(109) ?
<p>Let <span style="font-weight:bold;">A</span> and <span style="font-weight:bold;">B</span> be bit strings (sequences of 0's and 1's).<br> If <span style="font-weight:bold;">A</span> is equal to the <span style="text-decoration:underline;">left</span>most length(<span style="font-weight:bold;">A</span>) bits of <span style="font-weight:bold;">B</span>, then <span style="font-weight:bold;">A</span> is said to be a <span style="font-style:italic;">prefix</span> of <span style="font-weight:bold;">B</span>.<br> For example, 00110 is a prefix of <span style="text-decoration:underline;">00110</span>1001, but not of 00111 or 100110.</p> <p>A <span style="font-style:italic;">prefix-free code of size</span> <var>n</var> is a collection of <var>n</var> distinct bit strings such that no string is a prefix of any other. For example, this is a prefix-free code of size 6:</p> <p class="center">0000, 0001, 001, 01, 10, 11</p> <p>Now suppose that it costs one penny to transmit a '0' bit, but four pence to transmit a '1'.<br> Then the total cost of the prefix-free code shown above is 35 pence, which happens to be the cheapest possible for the skewed pricing scheme in question.<br> In short, we write Cost(6) = 35.</p> <p>What is Cost(10<sup>9</sup>) ?</p>
https://projecteuler.net/problem=219
64564225042
220
Let $D_0$ be the two-letter string "Fa". For $n\ge 1$, derive $D_n$ from $D_{n-1}$ by the string-rewriting rules: "a" → "aRbFR" "b" → "LFaLb" Thus, $D_0 = $ "Fa", $D_1 = $ "FaRbFR", $D_2 = $ "FaRbFRRLFaLbFR", and so on. These strings can be interpreted as instructions to a computer graphics program, with "F" meaning "draw forward one unit", "L" meaning "turn left $90$ degrees", "R" meaning "turn right $90$ degrees", and "a" and "b" being ignored. The initial position of the computer cursor is $(0,0)$, pointing up towards $(0,1)$. Then $D_n$ is an exotic drawing known as the Heighway Dragon of order $n$. For example, $D_{10}$ is shown below; counting each "F" as one step, the highlighted spot at $(18,16)$ is the position reached after $500$ steps. What is the position of the cursor after $10^{12}$ steps in $D_{50}$? Give your answer in the form x,y with no spaces.
<p>Let $D_0$ be the two-letter string "Fa". For $n\ge 1$, derive $D_n$ from $D_{n-1}$ by the string-rewriting rules:</p> <p style="margin-left:40px;">"a" → "aRbFR"<br> "b" → "LFaLb"</p> <p>Thus, $D_0 = $ "Fa", $D_1 = $ "FaRbFR", $D_2 = $ "FaRbFRRLFaLbFR", and so on.</p> <p>These strings can be interpreted as instructions to a computer graphics program, with "F" meaning "draw forward one unit", "L" meaning "turn left $90$ degrees", "R" meaning "turn right $90$ degrees", and "a" and "b" being ignored. The initial position of the computer cursor is $(0,0)$, pointing up towards $(0,1)$.</p> <p>Then $D_n$ is an exotic drawing known as the <strong>Heighway Dragon</strong> of order $n$. For example, $D_{10}$ is shown below; counting each "F" as one step, the highlighted spot at $(18,16)$ is the position reached after $500$ steps.</p> <div class="center"> <img src="resources/images/0220.gif?1678992055" class="dark_img" alt=""></div> <p>What is the position of the cursor after $10^{12}$ steps in $D_{50}$?<br> Give your answer in the form <i>x</i>,<i>y</i> with no spaces.</p>
https://projecteuler.net/problem=220
139776,963904
221
We shall call a positive integer $A$ an "Alexandrian integer", if there exist integers $p, q, r$ such that: $$A = p \cdot q \cdot r$$ and $$\dfrac{1}{A} = \dfrac{1}{p} + \dfrac{1}{q} + \dfrac{1}{r}.$$ For example, $630$ is an Alexandrian integer ($p = 5, q = -7, r = -18$). In fact, $630$ is the $6$th Alexandrian integer, the first $6$ Alexandrian integers being: $6, 42, 120, 156, 420$, and $630$. Find the $150000$th Alexandrian integer.
<p>We shall call a positive integer $A$ an "Alexandrian integer", if there exist integers $p, q, r$ such that:</p> <p class="center">$$A = p \cdot q \cdot r$$ and $$\dfrac{1}{A} = \dfrac{1}{p} + \dfrac{1}{q} + \dfrac{1}{r}.$$</p> <p>For example, $630$ is an Alexandrian integer ($p = 5, q = -7, r = -18$). In fact, $630$ is the $6$<sup>th</sup> Alexandrian integer, the first $6$ Alexandrian integers being: $6, 42, 120, 156, 420$, and $630$.</p> <p>Find the $150000$<sup>th</sup> Alexandrian integer.</p>
https://projecteuler.net/problem=221
1884161251122450
222
What is the length of the shortest pipe, of internal radius $\pu{50 mm}$, that can fully contain $21$ balls of radii $\pu{30 mm}, \pu{31 mm}, \dots, \pu{50 mm}$? Give your answer in micrometres ($\pu{10^{-6} m}$) rounded to the nearest integer.
<p>What is the length of the shortest pipe, of internal radius $\pu{50 mm}$, that can fully contain $21$ balls of radii $\pu{30 mm}, \pu{31 mm}, \dots, \pu{50 mm}$?</p> <p>Give your answer in micrometres ($\pu{10^{-6} m}$) rounded to the nearest integer.</p>
https://projecteuler.net/problem=222
1590933
223
Let us call an integer sided triangle with sides $a \le b \le c$ barely acute if the sides satisfy $a^2 + b^2 = c^2 + 1$. How many barely acute triangles are there with perimeter $\le 25\,000\,000$?
<p>Let us call an integer sided triangle with sides $a \le b \le c$ <dfn>barely acute</dfn> if the sides satisfy $a^2 + b^2 = c^2 + 1$.</p> <p>How many barely acute triangles are there with perimeter $\le 25\,000\,000$?</p>
https://projecteuler.net/problem=223
61614848
224
Let us call an integer sided triangle with sides $a \le b \le c$ barely obtuse if the sides satisfy $a^2 + b^2 = c^2 - 1$. How many barely obtuse triangles are there with perimeter $\le 75\,000\,000$?
<p>Let us call an integer sided triangle with sides $a \le b \le c$ <dfn>barely obtuse</dfn> if the sides satisfy <br>$a^2 + b^2 = c^2 - 1$.</p> <p>How many barely obtuse triangles are there with perimeter $\le 75\,000\,000$?</p>
https://projecteuler.net/problem=224
4137330
225
The sequence $1, 1, 1, 3, 5, 9, 17, 31, 57, 105, 193, 355, 653, 1201, \dots$ is defined by $T_1 = T_2 = T_3 = 1$ and $T_n = T_{n - 1} + T_{n - 2} + T_{n - 3}$. It can be shown that $27$ does not divide any terms of this sequence. In fact, $27$ is the first odd number with this property. Find the $124$th odd number that does not divide any terms of the above sequence.
<p> The sequence $1, 1, 1, 3, 5, 9, 17, 31, 57, 105, 193, 355, 653, 1201, \dots$<br> is defined by $T_1 = T_2 = T_3 = 1$ and $T_n = T_{n - 1} + T_{n - 2} + T_{n - 3}$. </p> <p> It can be shown that $27$ does not divide any terms of this sequence.<br>In fact, $27$ is the first odd number with this property.</p> <p> Find the $124$<sup>th</sup> odd number that does not divide any terms of the above sequence.</p>
https://projecteuler.net/problem=225
2009
226
The blancmange curve is the set of points $(x, y)$ such that $0 \le x \le 1$ and $y = \sum \limits_{n = 0}^{\infty} {\dfrac{s(2^n x)}{2^n}}$, where $s(x)$ is the distance from $x$ to the nearest integer. The area under the blancmange curve is equal to ½, shown in pink in the diagram below. Let $C$ be the circle with centre $\left ( \frac{1}{4}, \frac{1}{2} \right )$ and radius $\frac{1}{4}$, shown in black in the diagram. What area under the blancmange curve is enclosed by $C$? Give your answer rounded to eight decimal places in the form 0.abcdefgh.
<p>The <strong>blancmange curve</strong> is the set of points $(x, y)$ such that $0 \le x \le 1$ and $y = \sum \limits_{n = 0}^{\infty} {\dfrac{s(2^n x)}{2^n}}$, where $s(x)$ is the distance from $x$ to the nearest integer.</p> <p>The area under the blancmange curve is equal to ½, shown in pink in the diagram below.</p> <div class="center"> <img src="resources/images/0226_scoop2.gif?1678992055" class="dark_img" alt="blancmange curve"></div> <p>Let $C$ be the circle with centre $\left ( \frac{1}{4}, \frac{1}{2} \right )$ and radius $\frac{1}{4}$, shown in black in the diagram.</p> <p>What area under the blancmange curve is enclosed by $C$?<br>Give your answer rounded to eight decimal places in the form <i>0.abcdefgh</i>.</p>
https://projecteuler.net/problem=226
0.11316017
227
The Chase is a game played with two dice and an even number of players. The players sit around a table and the game begins with two opposite players having one die each. On each turn, the two players with a die roll it. If the player rolls 1, then the die passes to the neighbour on the left. If the player rolls 6, then the die passes to the neighbour on the right. Otherwise, the player keeps the die for the next turn. The game ends when one player has both dice after they have been rolled and passed; that player has then lost. In a game with 100 players, what is the expected number of turns the game lasts? Give your answer rounded to ten significant digits.
<p><dfn>The Chase</dfn> is a game played with two dice and an even number of players.</p> <p>The players sit around a table and the game begins with two opposite players having one die each. On each turn, the two players with a die roll it.</p> <p>If the player rolls 1, then the die passes to the neighbour on the left.<br> If the player rolls 6, then the die passes to the neighbour on the right.<br> Otherwise, the player keeps the die for the next turn.</p> <p>The game ends when one player has both dice after they have been rolled and passed; that player has then lost.</p> <p>In a game with 100 players, what is the expected number of turns the game lasts?</p> <p>Give your answer rounded to ten significant digits.</p>
https://projecteuler.net/problem=227
3780.618622
228
Let $S_n$ be the regular $n$-sided polygon – or shape – whose vertices $v_k$ ($k = 1, 2, \dots, n$) have coordinates: $$\begin{align} x_k &= \cos((2k - 1)/n \times 180^\circ)\\ y_k &= \sin((2k - 1)/n \times 180^\circ) \end{align}$$ Each $S_n$ is to be interpreted as a filled shape consisting of all points on the perimeter and in the interior. The Minkowski sum, $S + T$, of two shapes $S$ and $T$ is the result of adding every point in $S$ to every point in $T$, where point addition is performed coordinate-wise: $(u, v) + (x, y) = (u + x, v + y)$. For example, the sum of $S_3$ and $S_4$ is the six-sided shape shown in pink below: How many sides does $S_{1864} + S_{1865} + \cdots + S_{1909}$ have?
<p>Let $S_n$ be the regular $n$-sided polygon – or <dfn>shape</dfn> – whose vertices $v_k$ ($k = 1, 2, \dots, n$) have coordinates:</p> $$\begin{align} x_k &amp;= \cos((2k - 1)/n \times 180^\circ)\\ y_k &amp;= \sin((2k - 1)/n \times 180^\circ) \end{align}$$ <p>Each $S_n$ is to be interpreted as a filled shape consisting of all points on the perimeter and in the interior.</p> <p>The <strong>Minkowski sum</strong>, $S + T$, of two shapes $S$ and $T$ is the result of adding every point in $S$ to every point in $T$, where point addition is performed coordinate-wise: $(u, v) + (x, y) = (u + x, v + y)$.</p> <p>For example, the sum of $S_3$ and $S_4$ is the six-sided shape shown in pink below:</p> <div class="center"> <img src="resources/images/0228.png?1678992052" class="dark_img" alt="picture showing S_3 + S_4"></div> <p>How many sides does $S_{1864} + S_{1865} + \cdots + S_{1909}$ have?</p>
https://projecteuler.net/problem=228
86226
229
Consider the number $3600$. It is very special, because $$\begin{alignat}{2} 3600 &= 48^2 + &&36^2\\ 3600 &= 20^2 + 2 \times &&40^2\\ 3600 &= 30^2 + 3 \times &&30^2\\ 3600 &= 45^2 + 7 \times &&15^2 \end{alignat}$$ Similarly, we find that $88201 = 99^2 + 280^2 = 287^2 + 2 \times 54^2 = 283^2 + 3 \times 52^2 = 197^2 + 7 \times 84^2$. In 1747, Euler proved which numbers are representable as a sum of two squares. We are interested in the numbers $n$ which admit representations of all of the following four types: $$\begin{alignat}{2} n &= a_1^2 + && b_1^2\\ n &= a_2^2 + 2 && b_2^2\\ n &= a_3^2 + 3 && b_3^2\\ n &= a_7^2 + 7 && b_7^2, \end{alignat}$$ where the $a_k$ and $b_k$ are positive integers. There are $75373$ such numbers that do not exceed $10^7$. How many such numbers are there that do not exceed $2 \times 10^9$?
<p>Consider the number $3600$. It is very special, because</p> $$\begin{alignat}{2} 3600 &amp;= 48^2 + &amp;&amp;36^2\\ 3600 &amp;= 20^2 + 2 \times &amp;&amp;40^2\\ 3600 &amp;= 30^2 + 3 \times &amp;&amp;30^2\\ 3600 &amp;= 45^2 + 7 \times &amp;&amp;15^2 \end{alignat}$$ <p>Similarly, we find that $88201 = 99^2 + 280^2 = 287^2 + 2 \times 54^2 = 283^2 + 3 \times 52^2 = 197^2 + 7 \times 84^2$.</p> <p>In 1747, Euler proved which numbers are representable as a sum of two squares. We are interested in the numbers $n$ which admit representations of all of the following four types:</p> $$\begin{alignat}{2} n &amp;= a_1^2 + &amp;&amp; b_1^2\\ n &amp;= a_2^2 + 2 &amp;&amp; b_2^2\\ n &amp;= a_3^2 + 3 &amp;&amp; b_3^2\\ n &amp;= a_7^2 + 7 &amp;&amp; b_7^2, \end{alignat}$$ <p>where the $a_k$ and $b_k$ are positive integers.</p> <p>There are $75373$ such numbers that do not exceed $10^7$.<br> How many such numbers are there that do not exceed $2 \times 10^9$?</p>
https://projecteuler.net/problem=229
11325263
230
For any two strings of digits, $A$ and $B$, we define $F_{A, B}$ to be the sequence $(A,B,AB,BAB,ABBAB,\dots)$ in which each term is the concatenation of the previous two. Further, we define $D_{A, B}(n)$ to be the $n$th digit in the first term of $F_{A, B}$ that contains at least $n$ digits. Example: Let $A=1415926535$, $B=8979323846$. We wish to find $D_{A, B}(35)$, say. The first few terms of $F_{A, B}$ are: $1415926535$ $8979323846$ $14159265358979323846$ $897932384614159265358979323846$ $1415926535897932384689793238461415{\color{red}\mathbf 9}265358979323846$ Then $D_{A, B}(35)$ is the $35$th digit in the fifth term, which is $9$. Now we use for $A$ the first $100$ digits of $\pi$ behind the decimal point: $14159265358979323846264338327950288419716939937510$ $58209749445923078164062862089986280348253421170679$ and for $B$ the next hundred digits: $82148086513282306647093844609550582231725359408128$ $48111745028410270193852110555964462294895493038196$. Find $\sum_{n = 0}^{17} 10^n \times D_{A,B}((127+19n) \times 7^n)$.
<p>For any two strings of digits, $A$ and $B$, we define $F_{A, B}$ to be the sequence $(A,B,AB,BAB,ABBAB,\dots)$ in which each term is the concatenation of the previous two.</p> <p>Further, we define $D_{A, B}(n)$ to be the $n$<sup>th</sup> digit in the first term of $F_{A, B}$ that contains at least $n$ digits.</p> <p>Example:</p> <p>Let $A=1415926535$, $B=8979323846$. We wish to find $D_{A, B}(35)$, say.</p> <p>The first few terms of $F_{A, B}$ are:<br> $1415926535$<br> $8979323846$<br> $14159265358979323846$<br> $897932384614159265358979323846$<br> $1415926535897932384689793238461415{\color{red}\mathbf 9}265358979323846$<br></p> <p>Then $D_{A, B}(35)$ is the $35$<sup>th</sup> digit in the fifth term, which is $9$.</p> <p>Now we use for $A$ the first $100$ digits of $\pi$ behind the decimal point:</p> <p>$14159265358979323846264338327950288419716939937510$<br> $58209749445923078164062862089986280348253421170679$</p> <p>and for $B$ the next hundred digits:</p> <p>$82148086513282306647093844609550582231725359408128$<br> $48111745028410270193852110555964462294895493038196$.</p> <p>Find $\sum_{n = 0}^{17} 10^n \times D_{A,B}((127+19n) \times 7^n)$.</p>
https://projecteuler.net/problem=230
850481152593119296
231
The binomial coefficient $\displaystyle \binom {10} 3 = 120$. $120 = 2^3 \times 3 \times 5 = 2 \times 2 \times 2 \times 3 \times 5$, and $2 + 2 + 2 + 3 + 5 = 14$. So the sum of the terms in the prime factorisation of $\displaystyle \binom {10} 3$ is $14$. Find the sum of the terms in the prime factorisation of $\displaystyle \binom {20\,000\,000} {15\,000\,000}$.
<p>The binomial coefficient $\displaystyle \binom {10} 3 = 120$.<br> $120 = 2^3 \times 3 \times 5 = 2 \times 2 \times 2 \times 3 \times 5$, and $2 + 2 + 2 + 3 + 5 = 14$.<br> So the sum of the terms in the prime factorisation of $\displaystyle \binom {10} 3$ is $14$. <br><br> Find the sum of the terms in the prime factorisation of $\displaystyle \binom {20\,000\,000} {15\,000\,000}$. </p>
https://projecteuler.net/problem=231
7526965179680
232
Two players share an unbiased coin and take it in turns to play The Race. On Player 1's turn, the coin is tossed once. If it comes up Heads, then Player 1 scores one point; if it comes up Tails, then no points are scored. On Player 2's turn, a positive integer, $T$, is chosen by Player 2 and the coin is tossed $T$ times. If it comes up all Heads, then Player 2 scores $2^{T-1}$ points; otherwise, no points are scored. Player 1 goes first and the winner is the first to 100 or more points. Player 2 will always select the number, $T$, of coin tosses that maximises the probability of winning. What is the probability that Player 2 wins? Give your answer rounded to eight decimal places in the form 0.abcdefgh.
<p>Two players share an unbiased coin and take it in turns to play <dfn>The Race</dfn>.</p> <p>On Player 1's turn, the coin is tossed once. If it comes up Heads, then Player 1 scores one point; if it comes up Tails, then no points are scored.</p> <p>On Player 2's turn, a positive integer, $T$, is chosen by Player 2 and the coin is tossed $T$ times. If it comes up all Heads, then Player 2 scores $2^{T-1}$ points; otherwise, no points are scored.</p> <p>Player 1 goes first and the winner is the first to 100 or more points.</p> <p>Player 2 will always select the number, $T$, of coin tosses that maximises the probability of winning.</p> <p>What is the probability that Player 2 wins?</p> <p>Give your answer rounded to eight decimal places in the form 0.abcdefgh.</p>
https://projecteuler.net/problem=232
0.83648556
233
Let $f(N)$ be the number of points with integer coordinates that are on a circle passing through $(0,0)$, $(N,0)$,$(0,N)$, and $(N,N)$. It can be shown that $f(10000) = 36$. What is the sum of all positive integers $N \le 10^{11}$ such that $f(N) = 420$?
<p>Let $f(N)$ be the number of points with integer coordinates that are on a circle passing through $(0,0)$, $(N,0)$,$(0,N)$, and $(N,N)$.</p> <p>It can be shown that $f(10000) = 36$.</p> <p>What is the sum of all positive integers $N \le 10^{11}$ such that $f(N) = 420$?</p>
https://projecteuler.net/problem=233
271204031455541309
234
For an integer $n \ge 4$, we define the lower prime square root of $n$, denoted by $\operatorname{lps}(n)$, as the largest prime $\le \sqrt n$ and the upper prime square root of $n$, $\operatorname{ups}(n)$, as the smallest prime $\ge \sqrt n$. So, for example, $\operatorname{lps}(4) = 2 = \operatorname{ups}(4)$, $\operatorname{lps}(1000) = 31$, $\operatorname{ups}(1000) = 37$. Let us call an integer $n \ge 4$ semidivisible, if one of $\operatorname{lps}(n)$ and $\operatorname{ups}(n)$ divides $n$, but not both. The sum of the semidivisible numbers not exceeding $15$ is $30$, the numbers are $8$, $10$ and $12$. $15$ is not semidivisible because it is a multiple of both $\operatorname{lps}(15) = 3$ and $\operatorname{ups}(15) = 5$. As a further example, the sum of the $92$ semidivisible numbers up to $1000$ is $34825$. What is the sum of all semidivisible numbers not exceeding $999966663333$?
<p>For an integer $n \ge 4$, we define the <dfn>lower prime square root</dfn> of $n$, denoted by $\operatorname{lps}(n)$, as the largest prime $\le \sqrt n$ and the <dfn>upper prime square root</dfn> of $n$, $\operatorname{ups}(n)$, as the smallest prime $\ge \sqrt n$.</p> <p>So, for example, $\operatorname{lps}(4) = 2 = \operatorname{ups}(4)$, $\operatorname{lps}(1000) = 31$, $\operatorname{ups}(1000) = 37$.<br> Let us call an integer $n \ge 4$ <dfn>semidivisible</dfn>, if one of $\operatorname{lps}(n)$ and $\operatorname{ups}(n)$ divides $n$, but not both.</p> <p>The sum of the semidivisible numbers not exceeding $15$ is $30$, the numbers are $8$, $10$ and $12$.<br> $15$ is not semidivisible because it is a multiple of both $\operatorname{lps}(15) = 3$ and $\operatorname{ups}(15) = 5$.<br> As a further example, the sum of the $92$ semidivisible numbers up to $1000$ is $34825$.</p> <p>What is the sum of all semidivisible numbers not exceeding $999966663333$?</p>
https://projecteuler.net/problem=234
1259187438574927161
235
Given is the arithmetic-geometric sequence $u(k) = (900-3k)r^{k - 1}$. Let $s(n) = \sum_{k = 1}^n u(k)$. Find the value of $r$ for which $s(5000) = -600\,000\,000\,000$. Give your answer rounded to $12$ places behind the decimal point.
<p> Given is the arithmetic-geometric sequence $u(k) = (900-3k)r^{k - 1}$.<br> Let $s(n) = \sum_{k = 1}^n u(k)$. </p> <p> Find the value of $r$ for which $s(5000) = -600\,000\,000\,000$. </p> <p> Give your answer rounded to $12$ places behind the decimal point. </p>
https://projecteuler.net/problem=235
1.002322108633
236
Suppliers 'A' and 'B' provided the following numbers of products for the luxury hamper market: | Product | 'A' | 'B' | | --- | --- | --- | | Beluga Caviar | 5248 | 640 | | Christmas Cake | 1312 | 1888 | | Gammon Joint | 2624 | 3776 | | Vintage Port | 5760 | 3776 | | Champagne Truffles | 3936 | 5664 | Although the suppliers try very hard to ship their goods in perfect condition, there is inevitably some spoilage - i.e. products gone bad. The suppliers compare their performance using two types of statistic: - The five per-product spoilage rates for each supplier are equal to the number of products gone bad divided by the number of products supplied, for each of the five products in turn. - The overall spoilage rate for each supplier is equal to the total number of products gone bad divided by the total number of products provided by that supplier. To their surprise, the suppliers found that each of the five per-product spoilage rates was worse (higher) for 'B' than for 'A' by the same factor (ratio of spoilage rates), m>1; and yet, paradoxically, the overall spoilage rate was worse for 'A' than for 'B', also by a factor of m. There are thirty-five m>1 for which this surprising result could have occurred, the smallest of which is 1476/1475. What's the largest possible value of m? Give your answer as a fraction reduced to its lowest terms, in the form u/v.
<p>Suppliers 'A' and 'B' provided the following numbers of products for the luxury hamper market:</p> <p></p><center><table class="p236"><tr><th>Product</th><th class="center">'A'</th><th class="center">'B'</th></tr><tr><td>Beluga Caviar</td><td>5248</td><td>640</td></tr><tr><td>Christmas Cake</td><td>1312</td><td>1888</td></tr><tr><td>Gammon Joint</td><td>2624</td><td>3776</td></tr><tr><td>Vintage Port</td><td>5760</td><td>3776</td></tr><tr><td>Champagne Truffles</td><td>3936</td><td>5664</td></tr></table></center> <p>Although the suppliers try very hard to ship their goods in perfect condition, there is inevitably some spoilage - <i>i.e.</i> products gone bad.</p> <p>The suppliers compare their performance using two types of statistic:</p><ul><li>The five <i>per-product spoilage rates</i> for each supplier are equal to the number of products gone bad divided by the number of products supplied, for each of the five products in turn.</li> <li>The <i>overall spoilage rate</i> for each supplier is equal to the total number of products gone bad divided by the total number of products provided by that supplier.</li></ul><p>To their surprise, the suppliers found that each of the five per-product spoilage rates was worse (higher) for 'B' than for 'A' by the same factor (ratio of spoilage rates), <var>m</var>&gt;1; and yet, paradoxically, the overall spoilage rate was worse for 'A' than for 'B', also by a factor of <var>m</var>.</p> <p>There are thirty-five <var>m</var>&gt;1 for which this surprising result could have occurred, the smallest of which is 1476/1475.</p> <p>What's the largest possible value of <var>m</var>?<br> Give your answer as a fraction reduced to its lowest terms, in the form <var>u</var>/<var>v</var>.</p>
https://projecteuler.net/problem=236
123/59
237
Let $T(n)$ be the number of tours over a $4 \times n$ playing board such that: - The tour starts in the top left corner. - The tour consists of moves that are up, down, left, or right one square. - The tour visits each square exactly once. - The tour ends in the bottom left corner. The diagram shows one tour over a $4 \times 10$ board: $T(10)$ is $2329$. What is $T(10^{12})$ modulo $10^8$?
<p>Let $T(n)$ be the number of tours over a $4 \times n$ playing board such that:</p> <ul><li>The tour starts in the top left corner.</li> <li>The tour consists of moves that are up, down, left, or right one square.</li> <li>The tour visits each square exactly once.</li> <li>The tour ends in the bottom left corner.</li> </ul><p>The diagram shows one tour over a $4 \times 10$ board:</p> <div class="center"> <img src="resources/images/0237.gif?1678992055" class="dark_img" alt=""></div> <p>$T(10)$ is $2329$. What is $T(10^{12})$ modulo $10^8$?</p>
https://projecteuler.net/problem=237
15836928
238
Create a sequence of numbers using the "Blum Blum Shub" pseudo-random number generator: $$\begin{align} s_0 &= 14025256\\ s_{n + 1} &= s_n^2 \bmod 20300713 \end{align}$$ Concatenate these numbers $s_0s_1s_2\cdots$ to create a string $w$ of infinite length. Then, $w = {\color{blue}14025256741014958470038053646\cdots}$ For a positive integer $k$, if no substring of $w$ exists with a sum of digits equal to $k$, $p(k)$ is defined to be zero. If at least one substring of $w$ exists with a sum of digits equal to $k$, we define $p(k) = z$, where $z$ is the starting position of the earliest such substring. For instance: The substrings $\color{blue}1, 14, 1402, \dots$ with respective sums of digits equal to $1, 5, 7, \dots$ start at position $\mathbf 1$, hence $p(1) = p(5) = p(7) = \cdots = \mathbf 1$. The substrings $\color{blue}4, 402, 4025, \dots$ with respective sums of digits equal to $4, 6, 11, \dots$ start at position $\mathbf 2$, hence $p(4) = p(6) = p(11) = \cdots = \mathbf 2$. The substrings $\color{blue}02, 0252, \dots$ with respective sums of digits equal to $2, 9, \dots$ start at position $\mathbf 3$, hence $p(2) = p(9) = \cdots = \mathbf 3$. Note that substring $\color{blue}025$ starting at position $\mathbf 3$, has a sum of digits equal to $7$, but there was an earlier substring (starting at position $\mathbf 1$) with a sum of digits equal to $7$, so $p(7) = 1$, not $3$. We can verify that, for $0 \lt k \le 10^3$, $\sum p(k) = 4742$. Find $\sum p(k)$, for $0 \lt k \le 2 \times 10^{15}$.
<p>Create a sequence of numbers using the "Blum Blum Shub" pseudo-random number generator:</p> $$\begin{align} s_0 &amp;= 14025256\\ s_{n + 1} &amp;= s_n^2 \bmod 20300713 \end{align}$$ <p>Concatenate these numbers $s_0s_1s_2\cdots$ to create a string $w$ of infinite length.<br> Then, $w = {\color{blue}14025256741014958470038053646\cdots}$</p> <p>For a positive integer $k$, if no substring of $w$ exists with a sum of digits equal to $k$, $p(k)$ is defined to be zero. If at least one substring of $w$ exists with a sum of digits equal to $k$, we define $p(k) = z$, where $z$ is the starting position of the earliest such substring.</p> <p>For instance:</p> <p>The substrings $\color{blue}1, 14, 1402, \dots$<br> with respective sums of digits equal to $1, 5, 7, \dots$<br> start at position $\mathbf 1$, hence $p(1) = p(5) = p(7) = \cdots = \mathbf 1$.</p> <p>The substrings $\color{blue}4, 402, 4025, \dots$<br> with respective sums of digits equal to $4, 6, 11, \dots$<br> start at position $\mathbf 2$, hence $p(4) = p(6) = p(11) = \cdots = \mathbf 2$.</p> <p>The substrings $\color{blue}02, 0252, \dots$<br> with respective sums of digits equal to $2, 9, \dots$<br> start at position $\mathbf 3$, hence $p(2) = p(9) = \cdots = \mathbf 3$.</p> <p>Note that substring $\color{blue}025$ starting at position $\mathbf 3$, has a sum of digits equal to $7$, but there was an earlier substring (starting at position $\mathbf 1$) with a sum of digits equal to $7$, so $p(7) = 1$, <i>not</i> $3$.</p> <p>We can verify that, for $0 \lt k \le 10^3$, $\sum p(k) = 4742$.</p> <p>Find $\sum p(k)$, for $0 \lt k \le 2 \times 10^{15}$.</p>
https://projecteuler.net/problem=238
9922545104535661
239
A set of disks numbered $1$ through $100$ are placed in a line in random order. What is the probability that we have a partial derangement such that exactly $22$ prime number discs are found away from their natural positions? (Any number of non-prime disks may also be found in or out of their natural positions.) Give your answer rounded to $12$ places behind the decimal point in the form 0.abcdefghijkl.
<p>A set of disks numbered $1$ through $100$ are placed in a line in random order.</p> <p>What is the probability that we have a partial derangement such that exactly $22$ prime number discs are found away from their natural positions?<br> (Any number of non-prime disks may also be found in or out of their natural positions.)</p> <p>Give your answer rounded to $12$ places behind the decimal point in the form 0.abcdefghijkl.</p>
https://projecteuler.net/problem=239
0.001887854841
240
There are $1111$ ways in which five $6$-sided dice (sides numbered $1$ to $6$) can be rolled so that the top three sum to $15$. Some examples are: $D_1,D_2,D_3,D_4,D_5 = 4,3,6,3,5$ $D_1,D_2,D_3,D_4,D_5 = 4,3,3,5,6$ $D_1,D_2,D_3,D_4,D_5 = 3,3,3,6,6$ $D_1,D_2,D_3,D_4,D_5 = 6,6,3,3,3$ In how many ways can twenty $12$-sided dice (sides numbered $1$ to $12$) be rolled so that the top ten sum to $70$?
<p>There are $1111$ ways in which five $6$-sided dice (sides numbered $1$ to $6$) can be rolled so that the top three sum to $15$. Some examples are: <br><br> $D_1,D_2,D_3,D_4,D_5 = 4,3,6,3,5$ <br> $D_1,D_2,D_3,D_4,D_5 = 4,3,3,5,6$ <br> $D_1,D_2,D_3,D_4,D_5 = 3,3,3,6,6$ <br> $D_1,D_2,D_3,D_4,D_5 = 6,6,3,3,3$ <br><br> In how many ways can twenty $12$-sided dice (sides numbered $1$ to $12$) be rolled so that the top ten sum to $70$?</p>
https://projecteuler.net/problem=240
7448717393364181966
241
For a positive integer $n$, let $\sigma(n)$ be the sum of all divisors of $n$. For example, $\sigma(6) = 1 + 2 + 3 + 6 = 12$. A perfect number, as you probably know, is a number with $\sigma(n) = 2n$. Let us define the perfection quotient of a positive integer as $p(n) = \dfrac{\sigma(n)}{n}$. Find the sum of all positive integers $n \le 10^{18}$ for which $p(n)$ has the form $k + \dfrac{1}{2}$, where $k$ is an integer.
<p>For a positive integer $n$, let $\sigma(n)$ be the sum of all divisors of $n$. For example, $\sigma(6) = 1 + 2 + 3 + 6 = 12$.</p> <p>A perfect number, as you probably know, is a number with $\sigma(n) = 2n$.</p> <p>Let us define the <b>perfection quotient</b> of a positive integer as $p(n) = \dfrac{\sigma(n)}{n}$.</p> <p>Find the sum of all positive integers $n \le 10^{18}$ for which $p(n)$ has the form $k + \dfrac{1}{2}$, where $k$ is an integer.</p>
https://projecteuler.net/problem=241
482316491800641154
242
Given the set $\{1,2,\dots,n\}$, we define $f(n, k)$ as the number of its $k$-element subsets with an odd sum of elements. For example, $f(5,3) = 4$, since the set $\{1,2,3,4,5\}$ has four $3$-element subsets having an odd sum of elements, i.e.: $\{1,2,4\}$, $\{1,3,5\}$, $\{2,3,4\}$ and $\{2,4,5\}$. When all three values $n$, $k$ and $f(n, k)$ are odd, we say that they make an odd-triplet $[n,k,f(n, k)]$. There are exactly five odd-triplets with $n \le 10$, namely: $[1,1,f(1,1) = 1]$, $[5,1,f(5,1) = 3]$, $[5,5,f(5,5) = 1]$, $[9,1,f(9,1) = 5]$ and $[9,9,f(9,9) = 1]$. How many odd-triplets are there with $n \le 10^{12}$?
<p>Given the set $\{1,2,\dots,n\}$, we define $f(n, k)$ as the number of its $k$-element subsets with an odd sum of elements. For example, $f(5,3) = 4$, since the set $\{1,2,3,4,5\}$ has four $3$-element subsets having an odd sum of elements, i.e.: $\{1,2,4\}$, $\{1,3,5\}$, $\{2,3,4\}$ and $\{2,4,5\}$.</p> <p>When all three values $n$, $k$ and $f(n, k)$ are odd, we say that they make an <dfn>odd-triplet</dfn> $[n,k,f(n, k)]$.</p> <p>There are exactly five odd-triplets with $n \le 10$, namely:<br> $[1,1,f(1,1) = 1]$, $[5,1,f(5,1) = 3]$, $[5,5,f(5,5) = 1]$, $[9,1,f(9,1) = 5]$ and $[9,9,f(9,9) = 1]$.</p> <p>How many odd-triplets are there with $n \le 10^{12}$?</p>
https://projecteuler.net/problem=242
997104142249036713
243
A positive fraction whose numerator is less than its denominator is called a proper fraction. For any denominator, $d$, there will be $d - 1$ proper fractions; for example, with $d = 12$: $1 / 12, 2 / 12, 3 / 12, 4 / 12, 5 / 12, 6 / 12, 7 / 12, 8 / 12, 9 / 12, 10 / 12, 11 / 12$. We shall call a fraction that cannot be cancelled down a resilient fraction. Furthermore we shall define the resilience of a denominator, $R(d)$, to be the ratio of its proper fractions that are resilient; for example, $R(12) = 4/11$. In fact, $d = 12$ is the smallest denominator having a resilience $R(d) \lt 4/10$. Find the smallest denominator $d$, having a resilience $R(d) \lt 15499/94744$.
<p>A positive fraction whose numerator is less than its denominator is called a proper fraction.<br> For any denominator, $d$, there will be $d - 1$ proper fractions; for example, with $d = 12$:<br>$1 / 12, 2 / 12, 3 / 12, 4 / 12, 5 / 12, 6 / 12, 7 / 12, 8 / 12, 9 / 12, 10 / 12, 11 / 12$. </p> <p>We shall call a fraction that cannot be cancelled down a <dfn>resilient fraction</dfn>.<br> Furthermore we shall define the <dfn>resilience</dfn> of a denominator, $R(d)$, to be the ratio of its proper fractions that are resilient; for example, $R(12) = 4/11$.<br> In fact, $d = 12$ is the smallest denominator having a resilience $R(d) \lt 4/10$.</p> <p>Find the smallest denominator $d$, having a resilience $R(d) \lt 15499/94744$.</p>
https://projecteuler.net/problem=243
892371480
244
You probably know the game Fifteen Puzzle. Here, instead of numbered tiles, we have seven red tiles and eight blue tiles. A move is denoted by the uppercase initial of the direction (Left, Right, Up, Down) in which the tile is slid, e.g. starting from configuration (S), by the sequence LULUR we reach the configuration (E): | (S) | | , (E) | | For each path, its checksum is calculated by (pseudocode): $$\begin{align} \mathrm{checksum} &= 0\\ \mathrm{checksum} &= (\mathrm{checksum} \times 243 + m_1) \bmod 100\,000\,007\\ \mathrm{checksum} &= (\mathrm{checksum} \times 243 + m_2) \bmod 100\,000\,007\\ \cdots &\\ \mathrm{checksum} &= (\mathrm{checksum} \times 243 + m_n) \bmod 100\,000\,007 \end{align}$$ where $m_k$ is the ASCII value of the $k$th letter in the move sequence and the ASCII values for the moves are: | L | 76 | | R | 82 | | U | 85 | | D | 68 | For the sequence LULUR given above, the checksum would be $19761398$. Now, starting from configuration (S), find all shortest ways to reach configuration (T). | (S) | | , (T) | | What is the sum of all checksums for the paths having the minimal length?
<p>You probably know the game <strong>Fifteen Puzzle</strong>. Here, instead of numbered tiles, we have seven red tiles and eight blue tiles.</p> <p>A move is denoted by the uppercase initial of the direction (Left, Right, Up, Down) in which the tile is slid, e.g. starting from configuration (<b>S</b>), by the sequence <b>LULUR</b> we reach the configuration (<b>E</b>):</p> <p></p><div class="center"> <table cellspacing="0" cellpadding="2" border="0" align="center"><tr><td width="25">(<b>S</b>)</td><td width="100"><img src="resources/images/0244_start.gif?1678992055?1678992055" class="dark_img" alt="0244_start.gif"></td><td width="25">, (<b>E</b>)</td><td width="100"><img src="resources/images/0244_example.gif?1678992055" class="dark_img" alt="0244_example.gif"></td> </tr></table></div> <p>For each path, its checksum is calculated by (pseudocode): </p> $$\begin{align} \mathrm{checksum} &amp;= 0\\ \mathrm{checksum} &amp;= (\mathrm{checksum} \times 243 + m_1) \bmod 100\,000\,007\\ \mathrm{checksum} &amp;= (\mathrm{checksum} \times 243 + m_2) \bmod 100\,000\,007\\ \cdots &amp;\\ \mathrm{checksum} &amp;= (\mathrm{checksum} \times 243 + m_n) \bmod 100\,000\,007 \end{align}$$ where $m_k$ is the ASCII value of the $k$<sup><var>th</var></sup> letter in the move sequence and the ASCII values for the moves are: <div class="center"> <table cellspacing="0" cellpadding="2" border="1" align="center"><tr><td width="30"><b>L</b></td><td width="30">76</td></tr><tr><td><b>R</b></td><td>82</td></tr><tr><td><b>U</b></td><td>85</td></tr><tr><td><b>D</b></td><td>68</td></tr></table></div> <p>For the sequence <b>LULUR</b> given above, the checksum would be $19761398$.</p> <p>Now, starting from configuration (<b>S</b>), find all shortest ways to reach configuration (<b>T</b>).</p> <p></p><div class="center"> <table cellspacing="0" cellpadding="2" border="0" align="center"><tr><td width="25">(<b>S</b>)</td><td width="100"><img src="resources/images/0244_start.gif?1678992055?1678992055" class="dark_img" alt="0244_start.gif"></td><td width="25">, (<b>T</b>)</td><td width="100"><img src="resources/images/0244_target.gif?1678992055" class="dark_img" alt="0244_target.gif"></td> </tr></table></div> <p>What is the sum of all checksums for the paths having the minimal length?</p>
https://projecteuler.net/problem=244
96356848
245
We shall call a fraction that cannot be cancelled down a resilient fraction. Furthermore we shall define the resilience of a denominator, $R(d)$, to be the ratio of its proper fractions that are resilient; for example, $R(12) = \dfrac{4}{11}$. The resilience of a number $d \gt 1$ is then $\dfrac{\varphi(d)}{d - 1}$, where $\varphi$ is Euler's totient function. We further define the coresilience of a number $n \gt 1$ as $C(n) = \dfrac{n - \varphi(n)}{n - 1}$. The coresilience of a prime $p$ is $C(p) = \dfrac{1}{p - 1}$. Find the sum of all composite integers $1 \lt n \le 2 \times 10^{11}$, for which $C(n)$ is a unit fractionA fraction with numerator $1$.
<p>We shall call a fraction that cannot be cancelled down a resilient fraction.<br> Furthermore we shall define the resilience of a denominator, $R(d)$, to be the ratio of its proper fractions that are resilient; for example, $R(12) = \dfrac{4}{11}$.</p> <p>The resilience of a number $d \gt 1$ is then $\dfrac{\varphi(d)}{d - 1}$, where $\varphi$ is Euler's totient function.</p> <p>We further define the <dfn>coresilience</dfn> of a number $n \gt 1$ as $C(n) = \dfrac{n - \varphi(n)}{n - 1}$.</p> <p>The coresilience of a prime $p$ is $C(p) = \dfrac{1}{p - 1}$.</p> <p>Find the sum of all <strong>composite</strong> integers $1 \lt n \le 2 \times 10^{11}$, for which $C(n)$ is a <strong class="tooltip">unit fraction<span class="tooltiptext">A fraction with numerator $1$</span></strong>.</p>
https://projecteuler.net/problem=245
288084712410001
246
A definition for an ellipse is: Given a circle $c$ with centre $M$ and radius $r$ and a point $G$ such that $d(G,M) \lt r$, the locus of the points that are equidistant from $c$ and $G$ form an ellipse. The construction of the points of the ellipse is shown below. Given are the points $M(-2000,1500)$ and $G(8000,1500)$. Given is also the circle $c$ with centre $M$ and radius $15000$. The locus of the points that are equidistant from $G$ and $c$ form an ellipse $e$. From a point $P$ outside $e$ the two tangents $t_1$ and $t_2$ to the ellipse are drawn. Let the points where $t_1$ and $t_2$ touch the ellipse be $R$ and $S$. For how many lattice points $P$ is angle $RPS$ greater than $45$ degrees?
<p> A definition for an ellipse is:<br> Given a circle $c$ with centre $M$ and radius $r$ and a point $G$ such that $d(G,M) \lt r$, the locus of the points that are equidistant from $c$ and $G$ form an ellipse. </p> The construction of the points of the ellipse is shown below. <div class="center"> <img src="resources/images/0246_anim.gif?1678992055" class="dark_img" alt=""></div> <p> Given are the points $M(-2000,1500)$ and $G(8000,1500)$.<br> Given is also the circle $c$ with centre $M$ and radius $15000$.<br> The locus of the points that are equidistant from $G$ and $c$ form an ellipse $e$.<br> From a point $P$ outside $e$ the two tangents $t_1$ and $t_2$ to the ellipse are drawn.<br> Let the points where $t_1$ and $t_2$ touch the ellipse be $R$ and $S$. </p> <div class="center"> <img src="resources/images/0246_ellipse.gif?1678992055" class="dark_img" alt=""></div> <p> For how many lattice points $P$ is angle $RPS$ greater than $45$ degrees? </p>
https://projecteuler.net/problem=246
810834388
247
Consider the region constrained by $1 \le x$ and $0 \le y \le 1/x$. Let $S_1$ be the largest square that can fit under the curve. Let $S_2$ be the largest square that fits in the remaining area, and so on. Let the index of $S_n$ be the pair $(\text{left}, \text{below})$ indicating the number of squares to the left of $S_n$ and the number of squares below $S_n$. The diagram shows some such squares labelled by number. $S_2$ has one square to its left and none below, so the index of $S_2$ is $(1,0)$. It can be seen that the index of $S_{32}$ is $(1,1)$ as is the index of $S_{50}$. $50$ is the largest $n$ for which the index of $S_n$ is $(1,1)$. What is the largest $n$ for which the index of $S_n$ is $(3,3)$?
<p>Consider the region constrained by $1 \le x$ and $0 \le y \le 1/x$. </p><p> Let $S_1$ be the largest square that can fit under the curve.<br> Let $S_2$ be the largest square that fits in the remaining area, and so on. <br> Let the <dfn>index</dfn> of $S_n$ be the pair $(\text{left}, \text{below})$ indicating the number of squares to the left of $S_n$ and the number of squares below $S_n$. </p> <div class="center"> <img src="resources/images/0247_hypersquares.gif?1678992055" class="dark_img" alt=""></div> <p> The diagram shows some such squares labelled by number. <br> $S_2$ has one square to its left and none below, so the index of $S_2$ is $(1,0)$.<br> It can be seen that the index of $S_{32}$ is $(1,1)$ as is the index of $S_{50}$. <br> $50$ is the largest $n$ for which the index of $S_n$ is $(1,1)$. </p> <p> What is the largest $n$ for which the index of $S_n$ is $(3,3)$? </p>
https://projecteuler.net/problem=247
782252
248
The first number $n$ for which $\phi(n)=13!$ is $6227180929$. Find the $150\,000$th such number.
<p>The first number $n$ for which $\phi(n)=13!$ is $6227180929$.</p> <p>Find the $150\,000$<sup>th</sup> such number.</p>
https://projecteuler.net/problem=248
23507044290
249
Let $S = \{2, 3, 5, \dots, 4999\}$ be the set of prime numbers less than $5000$. Find the number of subsets of $S$, the sum of whose elements is a prime number. Enter the rightmost $16$ digits as your answer.
<p>Let $S = \{2, 3, 5, \dots, 4999\}$ be the set of prime numbers less than $5000$.</p> <p>Find the number of subsets of $S$, the sum of whose elements is a prime number.<br> Enter the rightmost $16$ digits as your answer.</p>
https://projecteuler.net/problem=249
9275262564250418
250
Find the number of non-empty subsets of $\{1^1, 2^2, 3^3,\dots, 250250^{250250}\}$, the sum of whose elements is divisible by $250$. Enter the rightmost $16$ digits as your answer.
<p>Find the number of non-empty subsets of $\{1^1, 2^2, 3^3,\dots, 250250^{250250}\}$, the sum of whose elements is divisible by $250$. Enter the rightmost $16$ digits as your answer.</p>
https://projecteuler.net/problem=250
1425480602091519
251
A triplet of positive integers $(a, b, c)$ is called a Cardano Triplet if it satisfies the condition: $$\sqrt[3]{a + b \sqrt{c}} + \sqrt[3]{a - b \sqrt{c}} = 1$$ For example, $(2,1,5)$ is a Cardano Triplet. There exist $149$ Cardano Triplets for which $a + b + c \le 1000$. Find how many Cardano Triplets exist such that $a + b + c \le 110\,000\,000$.
<p> A triplet of positive integers $(a, b, c)$ is called a Cardano Triplet if it satisfies the condition:</p> $$\sqrt[3]{a + b \sqrt{c}} + \sqrt[3]{a - b \sqrt{c}} = 1$$ <p> For example, $(2,1,5)$ is a Cardano Triplet. </p> <p> There exist $149$ Cardano Triplets for which $a + b + c \le 1000$. </p> <p> Find how many Cardano Triplets exist such that $a + b + c \le 110\,000\,000$. </p>
https://projecteuler.net/problem=251
18946051
252
Given a set of points on a plane, we define a convex hole to be a convex polygon having as vertices any of the given points and not containing any of the given points in its interior (in addition to the vertices, other given points may lie on the perimeter of the polygon). As an example, the image below shows a set of twenty points and a few such convex holes. The convex hole shown as a red heptagon has an area equal to $1049694.5$ square units, which is the highest possible area for a convex hole on the given set of points. For our example, we used the first $20$ points $(T_{2k - 1}, T_{2k})$, for $k = 1,2,\dots,20$, produced with the pseudo-random number generator: $$\begin{align} S_0 &= 290797\\ S_{n + 1} &= S_n^2 \bmod 50515093\\ T_n &= (S_n \bmod 2000) - 1000 \end{align}$$ i.e. $(527, 144), (-488, 732), (-454, -947), \dots$ What is the maximum area for a convex hole on the set containing the first $500$ points in the pseudo-random sequence? Specify your answer including one digit after the decimal point.
<p> Given a set of points on a plane, we define a convex hole to be a convex polygon having as vertices any of the given points and not containing any of the given points in its interior (in addition to the vertices, other given points may lie on the perimeter of the polygon). </p> <p> As an example, the image below shows a set of twenty points and a few such convex holes. The convex hole shown as a red heptagon has an area equal to $1049694.5$ square units, which is the highest possible area for a convex hole on the given set of points. </p> <div class="center"> <img src="resources/images/0252_convexhole.gif?1678992056" class="dark_img" alt=""></div> <p> </p><p>For our example, we used the first $20$ points $(T_{2k - 1}, T_{2k})$, for $k = 1,2,\dots,20$, produced with the pseudo-random number generator:</p> $$\begin{align} S_0 &amp;= 290797\\ S_{n + 1} &amp;= S_n^2 \bmod 50515093\\ T_n &amp;= (S_n \bmod 2000) - 1000 \end{align}$$ <p> <i>i.e.</i> $(527, 144), (-488, 732), (-454, -947), \dots$ </p> <p> What is the maximum area for a convex hole on the set containing the first $500$ points in the pseudo-random sequence?<br> Specify your answer including one digit after the decimal point. </p>
https://projecteuler.net/problem=252
104924.0
253
A small child has a “number caterpillar” consisting of forty jigsaw pieces, each with one number on it, which, when connected together in a line, reveal the numbers $1$ to $40$ in order. Every night, the child's father has to pick up the pieces of the caterpillar that have been scattered across the play room. He picks up the pieces at random and places them in the correct order. As the caterpillar is built up in this way, it forms distinct segments that gradually merge together. The number of segments starts at zero (no pieces placed), generally increases up to about eleven or twelve, then tends to drop again before finishing at a single segment (all pieces placed). For example: | Piece Placed | Segments So Far | | --- | --- | | 12 | 1 | | 4 | 2 | | 29 | 3 | | 6 | 4 | | 34 | 5 | | 5 | 4 | | 35 | 4 | | … | … | Let $M$ be the maximum number of segments encountered during a random tidy-up of the caterpillar. For a caterpillar of ten pieces, the number of possibilities for each $M$ is | M | Possibilities | | --- | --- | | 1 | 512 | | 2 | 250912 | | 3 | 1815264 | | 4 | 1418112 | | 5 | 144000 | so the most likely value of $M$ is $3$ and the average value is $385643/113400 = 3.400732$, rounded to six decimal places. The most likely value of $M$ for a forty-piece caterpillar is $11$; but what is the average value of $M$? Give your answer rounded to six decimal places.
<p>A small child has a “number caterpillar” consisting of forty jigsaw pieces, each with one number on it, which, when connected together in a line, reveal the numbers $1$ to $40$ in order.</p> <p>Every night, the child's father has to pick up the pieces of the caterpillar that have been scattered across the play room. He picks up the pieces at random and places them in the correct order.<br> As the caterpillar is built up in this way, it forms distinct segments that gradually merge together.<br> The number of segments starts at zero (no pieces placed), generally increases up to about eleven or twelve, then tends to drop again before finishing at a single segment (all pieces placed).</p><p> </p><p>For example:</p> <div class="center"> <table class="grid" style="margin:0 auto;"><tr><th width="80" align="center"><b>Piece Placed</b></th> <th width="80" align="center"><b>Segments So Far</b></th></tr> <tr><td align="center">12</td><td align="center">1</td></tr><tr><td align="center">4</td><td align="center">2</td></tr><tr><td align="center">29</td><td align="center">3</td></tr><tr><td align="center">6</td><td align="center">4</td></tr><tr><td align="center">34</td><td align="center">5</td></tr><tr><td align="center">5</td><td align="center">4</td></tr><tr><td align="center">35</td><td align="center">4</td></tr><tr><td align="center">…</td><td align="center">…</td></tr></table></div> <p>Let $M$ be the maximum number of segments encountered during a random tidy-up of the caterpillar.<br> For a caterpillar of ten pieces, the number of possibilities for each $M$ is</p> <div class="center"> <table class="grid" style="margin:0 auto;"><tr><th width="50" align="center"><b><var>M</var></b></th> <th width="90" align="center"><b>Possibilities</b></th></tr> <tr><td align="center">1</td><td align="right">512      </td></tr><tr><td align="center">2</td><td align="right">250912      </td></tr><tr><td align="center">3</td><td align="right">1815264      </td></tr><tr><td align="center">4</td><td align="right">1418112      </td></tr><tr><td align="center">5</td><td align="right">144000      </td></tr></table></div> <p>so the most likely value of $M$ is $3$ and the average value is $385643/113400 = 3.400732$, rounded to six decimal places.</p> <p>The most likely value of $M$ for a forty-piece caterpillar is $11$; but what is the average value of $M$?</p> <p>Give your answer rounded to six decimal places.</p>
https://projecteuler.net/problem=253
11.492847
254
Define $f(n)$ as the sum of the factorials of the digits of $n$. For example, $f(342) = 3! + 4! + 2! = 32$. Define $sf(n)$ as the sum of the digits of $f(n)$. So $sf(342) = 3 + 2 = 5$. Define $g(i)$ to be the smallest positive integer $n$ such that $sf(n) = i$. Though $sf(342)$ is $5$, $sf(25)$ is also $5$, and it can be verified that $g(5)$ is $25$. Define $sg(i)$ as the sum of the digits of $g(i)$. So $sg(5) = 2 + 5 = 7$. Further, it can be verified that $g(20)$ is $267$ and $\sum sg(i)$ for $1 \le i \le 20$ is $156$. What is $\sum sg(i)$ for $1 \le i \le 150$?
<p>Define $f(n)$ as the sum of the factorials of the digits of $n$. For example, $f(342) = 3! + 4! + 2! = 32$.</p> <p>Define $sf(n)$ as the sum of the digits of $f(n)$. So $sf(342) = 3 + 2 = 5$.</p> <p>Define $g(i)$ to be the smallest positive integer $n$ such that $sf(n) = i$. Though $sf(342)$ is $5$, $sf(25)$ is also $5$, and it can be verified that $g(5)$ is $25$.</p> <p>Define $sg(i)$ as the sum of the digits of $g(i)$. So $sg(5) = 2 + 5 = 7$.</p> <p>Further, it can be verified that $g(20)$ is $267$ and $\sum sg(i)$ for $1 \le i \le 20$ is $156$.</p> <p>What is $\sum sg(i)$ for $1 \le i \le 150$?</p>
https://projecteuler.net/problem=254
8184523820510
255
We define the rounded-square-root of a positive integer $n$ as the square root of $n$ rounded to the nearest integer. The following procedure (essentially Heron's method adapted to integer arithmetic) finds the rounded-square-root of $n$: Let $d$ be the number of digits of the number $n$. If $d$ is odd, set $x_0 = 2 \times 10^{(d-1)/2}$. If $d$ is even, set $x_0 = 7 \times 10^{(d-2)/2}$. Repeat: $$x_{k+1} = \Biggl\lfloor{\dfrac{x_k + \lceil{n / x_k}\rceil}{2}}\Biggr\rfloor$$ until $x_{k+1} = x_k$. As an example, let us find the rounded-square-root of $n = 4321$. $n$ has $4$ digits, so $x_0 = 7 \times 10^{(4-2)/2} = 70$. $$x_1 = \Biggl\lfloor{\dfrac{70 + \lceil{4321 / 70}\rceil}{2}}\Biggr\rfloor = 66$$ $$x_2 = \Biggl\lfloor{\dfrac{66 + \lceil{4321 / 66}\rceil}{2}}\Biggr\rfloor = 66$$ Since $x_2 = x_1$, we stop here. So, after just two iterations, we have found that the rounded-square-root of $4321$ is $66$ (the actual square root is $65.7343137\cdots$). The number of iterations required when using this method is surprisingly low. For example, we can find the rounded-square-root of a $5$-digit integer ($10\,000 \le n \le 99\,999$) with an average of $3.2102888889$ iterations (the average value was rounded to $10$ decimal places). Using the procedure described above, what is the average number of iterations required to find the rounded-square-root of a $14$-digit number ($10^{13} \le n \lt 10^{14}$)? Give your answer rounded to $10$ decimal places. Note: The symbols $\lfloor x \rfloor$ and $\lceil x \rceil$ represent the floor functionthe largest integer not greater than $x$ and ceiling functionthe smallest integer not less than $x$ respectively.
<p>We define the <dfn>rounded-square-root</dfn> of a positive integer $n$ as the square root of $n$ rounded to the nearest integer.</p> <p>The following procedure (essentially Heron's method adapted to integer arithmetic) finds the rounded-square-root of $n$:</p> <p>Let $d$ be the number of digits of the number $n$.<br> If $d$ is odd, set $x_0 = 2 \times 10^{(d-1)/2}$.<br> If $d$ is even, set $x_0 = 7 \times 10^{(d-2)/2}$.<br> Repeat:</p> $$x_{k+1} = \Biggl\lfloor{\dfrac{x_k + \lceil{n / x_k}\rceil}{2}}\Biggr\rfloor$$ <p>until $x_{k+1} = x_k$.</p> <p>As an example, let us find the rounded-square-root of $n = 4321$.<br>$n$ has $4$ digits, so $x_0 = 7 \times 10^{(4-2)/2} = 70$.<br> $$x_1 = \Biggl\lfloor{\dfrac{70 + \lceil{4321 / 70}\rceil}{2}}\Biggr\rfloor = 66$$ $$x_2 = \Biggl\lfloor{\dfrac{66 + \lceil{4321 / 66}\rceil}{2}}\Biggr\rfloor = 66$$ Since $x_2 = x_1$, we stop here.<br> So, after just two iterations, we have found that the rounded-square-root of $4321$ is $66$ (the actual square root is $65.7343137\cdots$). </p> <p>The number of iterations required when using this method is surprisingly low.<br> For example, we can find the rounded-square-root of a $5$-digit integer ($10\,000 \le n \le 99\,999$) with an average of $3.2102888889$ iterations (the average value was rounded to $10$ decimal places). </p> <p>Using the procedure described above, what is the average number of iterations required to find the rounded-square-root of a $14$-digit number ($10^{13} \le n \lt 10^{14}$)?<br> Give your answer rounded to $10$ decimal places. </p> <p>Note: The symbols $\lfloor x \rfloor$ and $\lceil x \rceil$ represent the <strong class="tooltip">floor function<span class="tooltiptext">the largest integer not greater than $x$</span></strong> and <strong class="tooltip">ceiling function<span class="tooltiptext">the smallest integer not less than $x$</span></strong> respectively. </p>
https://projecteuler.net/problem=255
4.4474011180
256
Tatami are rectangular mats, used to completely cover the floor of a room, without overlap. Assuming that the only type of available tatami has dimensions $1 \times 2$, there are obviously some limitations for the shape and size of the rooms that can be covered. For this problem, we consider only rectangular rooms with integer dimensions $a, b$ and even size $s = a \cdot b$. We use the term 'size' to denote the floor surface area of the room, and — without loss of generality — we add the condition $a \le b$. There is one rule to follow when laying out tatami: there must be no points where corners of four different mats meet. For example, consider the two arrangements below for a $4 \times 4$ room: The arrangement on the left is acceptable, whereas the one on the right is not: a red "X" in the middle, marks the point where four tatami meet. Because of this rule, certain even-sized rooms cannot be covered with tatami: we call them tatami-free rooms. Further, we define $T(s)$ as the number of tatami-free rooms of size $s$. The smallest tatami-free room has size $s = 70$ and dimensions $7 \times 10$. All the other rooms of size $s = 70$ can be covered with tatami; they are: $1 \times 70$, $2 \times 35$ and $5 \times 14$. Hence, $T(70) = 1$. Similarly, we can verify that $T(1320) = 5$ because there are exactly $5$ tatami-free rooms of size $s = 1320$: $20 \times 66$, $22 \times 60$, $24 \times 55$, $30 \times 44$ and $33 \times 40$. In fact, $s = 1320$ is the smallest room-size $s$ for which $T(s) = 5$. Find the smallest room-size $s$ for which $T(s) = 200$.
<p>Tatami are rectangular mats, used to completely cover the floor of a room, without overlap.</p> <p>Assuming that the only type of available tatami has dimensions $1 \times 2$, there are obviously some limitations for the shape and size of the rooms that can be covered.</p> <p>For this problem, we consider only rectangular rooms with integer dimensions $a, b$ and even size $s = a \cdot b$.<br> We use the term 'size' to denote the floor surface area of the room, and — without loss of generality — we add the condition $a \le b$.</p> <p>There is one rule to follow when laying out tatami: there must be no points where corners of four different mats meet.<br> For example, consider the two arrangements below for a $4 \times 4$ room:</p> <div align="center"> <img src="resources/images/0256_tatami3.gif?1678992056" alt="0256_tatami3.gif"><br></div> <p>The arrangement on the left is acceptable, whereas the one on the right is not: a red "<span style="color:#FF0000;"><b>X</b></span>" in the middle, marks the point where four tatami meet.</p> <p>Because of this rule, certain even-sized rooms cannot be covered with tatami: we call them tatami-free rooms.<br> Further, we define $T(s)$ as the number of tatami-free rooms of size $s$.</p> <p>The smallest tatami-free room has size $s = 70$ and dimensions $7 \times 10$.<br> All the other rooms of size $s = 70$ can be covered with tatami; they are: $1 \times 70$, $2 \times 35$ and $5 \times 14$.<br> Hence, $T(70) = 1$.</p> <p>Similarly, we can verify that $T(1320) = 5$ because there are exactly $5$ tatami-free rooms of size $s = 1320$:<br> $20 \times 66$, $22 \times 60$, $24 \times 55$, $30 \times 44$ and $33 \times 40$.<br> In fact, $s = 1320$ is the smallest room-size $s$ for which $T(s) = 5$.</p> <p>Find the smallest room-size $s$ for which $T(s) = 200$.</p>
https://projecteuler.net/problem=256
85765680
257
Given is an integer sided triangle $ABC$ with sides $a \le b \le c$. ($AB = c$, $BC = a$ and $AC = b$.) The angular bisectors of the triangle intersect the sides at points $E$, $F$ and $G$ (see picture below). The segments $EF$, $EG$ and $FG$ partition the triangle $ABC$ into four smaller triangles: $AEG$, $BFE$, $CGF$ and $EFG$. It can be proven that for each of these four triangles the ratio area($ABC$)/area(subtriangle) is rational. However, there exist triangles for which some or all of these ratios are integral. How many triangles $ABC$ with perimeter $\le 100\,000\,000$ exist so that the ratio area($ABC$)/area($AEG$) is integral?
<p>Given is an integer sided triangle $ABC$ with sides $a \le b \le c$. ($AB = c$, $BC = a$ and $AC = b$.)<br> The angular bisectors of the triangle intersect the sides at points $E$, $F$ and $G$ (see picture below). </p> <div align="center"> <img src="resources/images/0257_bisector.gif?1678992056" class="dark_img" alt="0257_bisector.gif"><br></div> <p> The segments $EF$, $EG$ and $FG$ partition the triangle $ABC$ into four smaller triangles: $AEG$, $BFE$, $CGF$ and $EFG$.<br> It can be proven that for each of these four triangles the ratio area($ABC$)/area(subtriangle) is rational.<br> However, there exist triangles for which some or all of these ratios are integral. </p> <p> How many triangles $ABC$ with perimeter $\le 100\,000\,000$ exist so that the ratio area($ABC$)/area($AEG$) is integral? </p>
https://projecteuler.net/problem=257
139012411
258
A sequence is defined as: - $g_k = 1$, for $0 \le k \le 1999$ - $g_k = g_{k-2000} + g_{k - 1999}$, for $k \ge 2000$. Find $g_k \bmod 20092010$ for $k = 10^{18}$.
<p>A sequence is defined as:</p> <p> </p><ul><li>$g_k = 1$, for $0 \le k \le 1999$</li> <li>$g_k = g_{k-2000} + g_{k - 1999}$, for $k \ge 2000$. </li></ul><p>Find $g_k \bmod 20092010$ for $k = 10^{18}$.</p>
https://projecteuler.net/problem=258
12747994
259
A positive integer will be called reachable if it can result from an arithmetic expression obeying the following rules: - Uses the digits $1$ through $9$, in that order and exactly once each. - Any successive digits can be concatenated (for example, using the digits $2$, $3$ and $4$ we obtain the number $234$). - Only the four usual binary arithmetic operations (addition, subtraction, multiplication and division) are allowed. - Each operation can be used any number of times, or not at all. - Unary minusA minus sign applied to a single operand (as opposed to a subtraction operator between two operands) is not allowed. - Any number of (possibly nested) parentheses may be used to define the order of operations. For example, $42$ is reachable, since $(1 / 23) \times ((4 \times 5) - 6) \times (78 - 9) = 42$. What is the sum of all positive reachable integers?
<p>A positive integer will be called <dfn>reachable</dfn> if it can result from an arithmetic expression obeying the following rules:</p> <ul><li>Uses the digits $1$ through $9$, in that order and exactly once each.</li> <li>Any successive digits can be concatenated (for example, using the digits $2$, $3$ and $4$ we obtain the number $234$).</li> <li>Only the four usual binary arithmetic operations (addition, subtraction, multiplication and division) are allowed.</li> <li>Each operation can be used any number of times, or not at all.</li> <li><strong class="tooltip">Unary minus<span class="tooltiptext">A minus sign applied to a single operand (as opposed to a subtraction operator between two operands)</span></strong> is not allowed.</li> <li>Any number of (possibly nested) parentheses may be used to define the order of operations.</li> </ul><p>For example, $42$ is reachable, since $(1 / 23) \times ((4 \times 5) - 6) \times (78 - 9) = 42$.</p> <p>What is the sum of all positive reachable integers?</p>
https://projecteuler.net/problem=259
20101196798
260
A game is played with three piles of stones and two players. On each player's turn, the player may remove one or more stones from the piles. However, if the player takes stones from more than one pile, then the same number of stones must be removed from each of the selected piles. In other words, the player chooses some $N \gt 0$ and removes: - $N$ stones from any single pile; or - $N$ stones from each of any two piles ($2N$ total); or - $N$ stones from each of the three piles ($3N$ total). The player taking the last stone(s) wins the game. A winning configuration is one where the first player can force a win. For example, $(0,0,13)$, $(0,11,11)$, and $(5,5,5)$ are winning configurations because the first player can immediately remove all stones. A losing configuration is one where the second player can force a win, no matter what the first player does. For example, $(0,1,2)$ and $(1,3,3)$ are losing configurations: any legal move leaves a winning configuration for the second player. Consider all losing configurations $(x_i, y_i, z_i)$ where $x_i \le y_i \le z_i \le 100$. We can verify that $\sum (x_i + y_i + z_i) = 173895$ for these. Find $\sum (x_i + y_i + z_i)$ where $(x_i, y_i, z_i)$ ranges over the losing configurations with $x_i \le y_i \le z_i \le 1000$.
<p>A game is played with three piles of stones and two players.<br> On each player's turn, the player may remove one or more stones from the piles. However, if the player takes stones from more than one pile, then the same number of stones must be removed from each of the selected piles.</p> <p>In other words, the player chooses some $N \gt 0$ and removes:</p> <ul> <li>$N$ stones from any single pile; or</li> <li>$N$ stones from each of any two piles ($2N$ total); or</li> <li>$N$ stones from each of the three piles ($3N$ total).</li> </ul> <p>The player taking the last stone(s) wins the game.</p> <p>A <dfn>winning configuration</dfn> is one where the first player can force a win.<br> For example, $(0,0,13)$, $(0,11,11)$, and $(5,5,5)$ are winning configurations because the first player can immediately remove all stones.</p> <p>A <dfn>losing configuration</dfn> is one where the second player can force a win, no matter what the first player does.<br> For example, $(0,1,2)$ and $(1,3,3)$ are losing configurations: any legal move leaves a winning configuration for the second player.</p> <p>Consider all losing configurations $(x_i, y_i, z_i)$ where $x_i \le y_i \le z_i \le 100$.<br> We can verify that $\sum (x_i + y_i + z_i) = 173895$ for these.</p> <p>Find $\sum (x_i + y_i + z_i)$ where $(x_i, y_i, z_i)$ ranges over the losing configurations with $x_i \le y_i \le z_i \le 1000$.</p>
https://projecteuler.net/problem=260
167542057
261
Let us call a positive integer $k$ a square-pivot, if there is a pair of integers $m \gt 0$ and $n \ge k$, such that the sum of the $(m+1)$ consecutive squares up to $k$ equals the sum of the $m$ consecutive squares from $(n+1)$ on: $$(k - m)^2 + \cdots + k^2 = (n + 1)^2 + \cdots + (n + m)^2.$$ Some small square-pivots are - $\mathbf 4$: $3^2 + \mathbf 4^2 = 5^2$ - $\mathbf{21}$: $20^2 + \mathbf{21}^2 = 29^2$ - $\mathbf{24}$: $21^2 + 22^2 + 23^2 + \mathbf{24}^2 = 25^2 + 26^2 + 27^2$ - $\mathbf{110}$: $108^2 + 109^2 + \mathbf{110}^2 = 133^2 + 134^2$ Find the sum of all distinct square-pivots $\le 10^{10}$.
<p>Let us call a positive integer $k$ a <dfn>square-pivot</dfn>, if there is a pair of integers $m \gt 0$ and $n \ge k$, such that the sum of the $(m+1)$ consecutive squares up to $k$ equals the sum of the $m$ consecutive squares from $(n+1)$ on:</p> $$(k - m)^2 + \cdots + k^2 = (n + 1)^2 + \cdots + (n + m)^2.$$ <p>Some small square-pivots are </p><ul><li>$\mathbf 4$: $3^2 + \mathbf 4^2 = 5^2$</li> <li>$\mathbf{21}$: $20^2 + \mathbf{21}^2 = 29^2$</li> <li>$\mathbf{24}$: $21^2 + 22^2 + 23^2 + \mathbf{24}^2 = 25^2 + 26^2 + 27^2$</li> <li>$\mathbf{110}$: $108^2 + 109^2 + \mathbf{110}^2 = 133^2 + 134^2$</li></ul><p>Find the sum of all <b>distinct</b> square-pivots $\le 10^{10}$.</p>
https://projecteuler.net/problem=261
238890850232021
262
The following equation represents the continuous topography of a mountainous region, giving the elevationheight above sea level $h$ at any point $(x, y)$: $$h = \left(5000 - \frac{x^2 + y^2 + xy}{200} + \frac{25(x + y)}2\right) \cdot e^{-\left|\frac{x^2 + y^2}{1000000} - \frac{3(x + y)}{2000} + \frac 7 {10}\right|}.$$ A mosquito intends to fly from $A(200,200)$ to $B(1400,1400)$, without leaving the area given by $0 \le x, y \le 1600$. Because of the intervening mountains, it first rises straight up to a point $A^\prime$, having elevation $f$. Then, while remaining at the same elevation $f$, it flies around any obstacles until it arrives at a point $B^\prime$ directly above $B$. First, determine $f_{\mathrm{min}}$ which is the minimum constant elevation allowing such a trip from $A$ to $B$, while remaining in the specified area. Then, find the length of the shortest path between $A^\prime$ and $B^\prime$, while flying at that constant elevation $f_{\mathrm{min}}$. Give that length as your answer, rounded to three decimal places. Note: For convenience, the elevation function shown above is repeated below, in a form suitable for most programming languages: h=( 5000-0.005*(x*x+y*y+x*y)+12.5*(x+y) ) * exp( -abs(0.000001*(x*x+y*y)-0.0015*(x+y)+0.7) )
<p>The following equation represents the <i>continuous</i> topography of a mountainous region, giving the <strong class="tooltip">elevation<span class="tooltiptext">height above sea level</span></strong> $h$ at any point $(x, y)$: $$h = \left(5000 - \frac{x^2 + y^2 + xy}{200} + \frac{25(x + y)}2\right) \cdot e^{-\left|\frac{x^2 + y^2}{1000000} - \frac{3(x + y)}{2000} + \frac 7 {10}\right|}.$$ </p> <p>A mosquito intends to fly from $A(200,200)$ to $B(1400,1400)$, without leaving the area given by $0 \le x, y \le 1600$.</p> <p>Because of the intervening mountains, it first rises straight up to a point $A^\prime$, having elevation $f$. Then, while remaining at the same elevation $f$, it flies around any obstacles until it arrives at a point $B^\prime$ directly above $B$.</p> <p>First, determine $f_{\mathrm{min}}$ which is the minimum constant elevation allowing such a trip from $A$ to $B$, while remaining in the specified area.<br> Then, find the length of the shortest path between $A^\prime$ and $B^\prime$, while flying at that constant elevation $f_{\mathrm{min}}$.</p> <p>Give that length as your answer, rounded to three decimal places.</p> <p><font><u>Note</u>: For convenience, the elevation function shown above is repeated below, in a form suitable for most programming languages:<br> h=( 5000-0.005*(x*x+y*y+x*y)+12.5*(x+y) ) * exp( -abs(0.000001*(x*x+y*y)-0.0015*(x+y)+0.7) )</font></p>
https://projecteuler.net/problem=262
2531.205
263
Consider the number $6$. The divisors of $6$ are: $1,2,3$ and $6$. Every number from $1$ up to and including $6$ can be written as a sum of distinct divisors of $6$: $1=1$, $2=2$, $3=1+2$, $4=1+3$, $5=2+3$, $6=6$. A number $n$ is called a practical number if every number from $1$ up to and including $n$ can be expressed as a sum of distinct divisors of $n$. A pair of consecutive prime numbers with a difference of six is called a sexy pair (since "sex" is the Latin word for "six"). The first sexy pair is $(23, 29)$. We may occasionally find a triple-pair, which means three consecutive sexy prime pairs, such that the second member of each pair is the first member of the next pair. We shall call a number $n$ such that : - $(n-9, n-3)$, $(n-3,n+3)$, $(n+3, n+9)$ form a triple-pair, and - the numbers $n-8$, $n-4$, $n$, $n+4$ and $n+8$ are all practical, an engineers’ paradise. Find the sum of the first four engineers’ paradises.
<p> Consider the number $6$. The divisors of $6$ are: $1,2,3$ and $6$.<br> Every number from $1$ up to and including $6$ can be written as a sum of distinct divisors of $6$:<br> $1=1$, $2=2$, $3=1+2$, $4=1+3$, $5=2+3$, $6=6$.<br> A number $n$ is called a practical number if every number from $1$ up to and including $n$ can be expressed as a sum of distinct divisors of $n$. </p> <p> A pair of consecutive prime numbers with a difference of six is called a sexy pair (since "sex" is the Latin word for "six"). The first sexy pair is $(23, 29)$. </p> <p> We may occasionally find a triple-pair, which means three consecutive sexy prime pairs, such that the second member of each pair is the first member of the next pair. </p> <p> We shall call a number $n$ such that : </p><ul><li>$(n-9, n-3)$, $(n-3,n+3)$, $(n+3, n+9)$ form a triple-pair, and </li><li>the numbers $n-8$, $n-4$, $n$, $n+4$ and $n+8$ are all practical, </li></ul> an engineers’ paradise. <p> Find the sum of the first four engineers’ paradises. </p>
https://projecteuler.net/problem=263
2039506520
264
Consider all the triangles having: - All their vertices on lattice pointsInteger coordinates. - CircumcentreCentre of the circumscribed circle at the origin $O$. - OrthocentrePoint where the three altitudes meet at the point $H(5, 0)$. There are nine such triangles having a perimeter $\le 50$. Listed and shown in ascending order of their perimeter, they are: | $A(-4, 3)$, $B(5, 0)$, $C(4, -3)$ $A(4, 3)$, $B(5, 0)$, $C(-4, -3)$ $A(-3, 4)$, $B(5, 0)$, $C(3, -4)$ $A(3, 4)$, $B(5, 0)$, $C(-3, -4)$ $A(0, 5)$, $B(5, 0)$, $C(0, -5)$ $A(1, 8)$, $B(8, -1)$, $C(-4, -7)$ $A(8, 1)$, $B(1, -8)$, $C(-4, 7)$ $A(2, 9)$, $B(9, -2)$, $C(-6, -7)$ $A(9, 2)$, $B(2, -9)$, $C(-6, 7)$ | | The sum of their perimeters, rounded to four decimal places, is $291.0089$. Find all such triangles with a perimeter $\le 10^5$. Enter as your answer the sum of their perimeters rounded to four decimal places.
<p>Consider all the triangles having: </p><ul><li>All their vertices on <strong class="tooltip">lattice points<span class="tooltiptext">Integer coordinates</span></strong>.</li> <li><strong class="tooltip">Circumcentre<span class="tooltiptext">Centre of the circumscribed circle</span></strong> at the origin $O$.</li> <li><strong class="tooltip">Orthocentre<span class="tooltiptext">Point where the three altitudes meet</span></strong> at the point $H(5, 0)$.</li> </ul><p>There are nine such triangles having a perimeter $\le 50$.<br> Listed and shown in ascending order of their perimeter, they are:</p> <p></p><table><tr><td>$A(-4, 3)$, $B(5, 0)$, $C(4, -3)$<br> $A(4, 3)$, $B(5, 0)$, $C(-4, -3)$<br> $A(-3, 4)$, $B(5, 0)$, $C(3, -4)$<br><br><br> $A(3, 4)$, $B(5, 0)$, $C(-3, -4)$<br> $A(0, 5)$, $B(5, 0)$, $C(0, -5)$<br> $A(1, 8)$, $B(8, -1)$, $C(-4, -7)$<br><br><br> $A(8, 1)$, $B(1, -8)$, $C(-4, 7)$<br> $A(2, 9)$, $B(9, -2)$, $C(-6, -7)$<br> $A(9, 2)$, $B(2, -9)$, $C(-6, 7)$<br></td> <td><img src="resources/images/0264_TriangleCentres.gif?1678992056" class="dark_img" alt="0264_TriangleCentres.gif"></td> </tr></table> <p>The sum of their perimeters, rounded to four decimal places, is $291.0089$.</p> <p>Find all such triangles with a perimeter $\le 10^5$.<br> Enter as your answer the sum of their perimeters rounded to four decimal places.</p>
https://projecteuler.net/problem=264
2816417.1055
265
$2^N$ binary digits can be placed in a circle so that all the $N$-digit clockwise subsequences are distinct. For $N=3$, two such circular arrangements are possible, ignoring rotations: For the first arrangement, the $3$-digit subsequences, in clockwise order, are: $000$, $001$, $010$, $101$, $011$, $111$, $110$ and $100$. Each circular arrangement can be encoded as a number by concatenating the binary digits starting with the subsequence of all zeros as the most significant bits and proceeding clockwise. The two arrangements for $N=3$ are thus represented as $23$ and $29$: $$\begin{align} 00010111_2 &= 23\\ 00011101_2 &= 29 \end{align}$$ Calling $S(N)$ the sum of the unique numeric representations, we can see that $S(3) = 23 + 29 = 52$. Find $S(5)$.
<p>$2^N$ binary digits can be placed in a circle so that all the $N$-digit clockwise subsequences are distinct.</p> <p>For $N=3$, two such circular arrangements are possible, ignoring rotations:</p> <div align="center"><img src="resources/images/0265_BinaryCircles.gif?1678992056" class="dark_img" alt="0265_BinaryCircles.gif"></div> <p>For the first arrangement, the $3$-digit subsequences, in clockwise order, are:<br>$000$, $001$, $010$, $101$, $011$, $111$, $110$ and $100$.</p> <p>Each circular arrangement can be encoded as a number by concatenating the binary digits starting with the subsequence of all zeros as the most significant bits and proceeding clockwise. The two arrangements for $N=3$ are thus represented as $23$ and $29$: </p> $$\begin{align} 00010111_2 &amp;= 23\\ 00011101_2 &amp;= 29 \end{align}$$ <p>Calling $S(N)$ the sum of the unique numeric representations, we can see that $S(3) = 23 + 29 = 52$.</p> <p>Find $S(5)$.</p>
https://projecteuler.net/problem=265
209110240768
266
The divisors of $12$ are: $1,2,3,4,6$ and $12$. The largest divisor of $12$ that does not exceed the square root of $12$ is $3$. We shall call the largest divisor of an integer $n$ that does not exceed the square root of $n$ the pseudo square root ($\operatorname{PSR}$) of $n$. It can be seen that $\operatorname{PSR}(3102)=47$. Let $p$ be the product of the primes below $190$. Find $\operatorname{PSR}(p) \bmod 10^{16}$.
<p> The divisors of $12$ are: $1,2,3,4,6$ and $12$.<br> The largest divisor of $12$ that does not exceed the square root of $12$ is $3$.<br> We shall call the largest divisor of an integer $n$ that does not exceed the square root of $n$ the pseudo square root ($\operatorname{PSR}$) of $n$.<br> It can be seen that $\operatorname{PSR}(3102)=47$. </p> <p> Let $p$ be the product of the primes below $190$.<br> Find $\operatorname{PSR}(p) \bmod 10^{16}$. </p>
https://projecteuler.net/problem=266
1096883702440585
267
You are given a unique investment opportunity. Starting with £1 of capital, you can choose a fixed proportion, f, of your capital to bet on a fair coin toss repeatedly for 1000 tosses. Your return is double your bet for heads and you lose your bet for tails. For example, if f = 1/4, for the first toss you bet £0.25, and if heads comes up you win £0.5 and so then have £1.5. You then bet £0.375 and if the second toss is tails, you have £1.125. Choosing f to maximize your chances of having at least £1,000,000,000 after 1,000 flips, what is the chance that you become a billionaire? All computations are assumed to be exact (no rounding), but give your answer rounded to 12 digits behind the decimal point in the form 0.abcdefghijkl.
<p>You are given a unique investment opportunity.</p> <p>Starting with £1 of capital, you can choose a fixed proportion, <var>f</var>, of your capital to bet on a fair coin toss repeatedly for 1000 tosses.</p> <p>Your return is double your bet for heads and you lose your bet for tails.</p> <p>For example, if <var>f</var> = 1/4, for the first toss you bet £0.25, and if heads comes up you win £0.5 and so then have £1.5. You then bet £0.375 and if the second toss is tails, you have £1.125.</p> <p>Choosing <var>f</var> to maximize your chances of having at least £1,000,000,000 after 1,000 flips, what is the chance that you become a billionaire?</p> <p>All computations are assumed to be exact (no rounding), but give your answer rounded to 12 digits behind the decimal point in the form 0.abcdefghijkl.</p>
https://projecteuler.net/problem=267
0.999992836187
268
It can be verified that there are $23$ positive integers less than $1000$ that are divisible by at least four distinct primes less than $100$. Find how many positive integers less than $10^{16}$ are divisible by at least four distinct primes less than $100$.
<p>It can be verified that there are $23$ positive integers less than $1000$ that are divisible by at least four distinct primes less than $100$.</p> <p>Find how many positive integers less than $10^{16}$ are divisible by at least four distinct primes less than $100$.</p>
https://projecteuler.net/problem=268
785478606870985
269
A root or zero of a polynomial $P(x)$ is a solution to the equation $P(x) = 0$. Define $P_n$ as the polynomial whose coefficients are the digits of $n$. For example, $P_{5703}(x) = 5x^3 + 7x^2 + 3$. We can see that: - $P_n(0)$ is the last digit of $n$, - $P_n(1)$ is the sum of the digits of $n$, - $P_n(10)$ is $n$ itself. Define $Z(k)$ as the number of positive integers, $n$, not exceeding $k$ for which the polynomial $P_n$ has at least one integer root. It can be verified that $Z(100\,000)$ is $14696$. What is $Z(10^{16})$?
<p>A root or zero of a polynomial $P(x)$ is a solution to the equation $P(x) = 0$. <br> Define $P_n$ as the polynomial whose coefficients are the digits of $n$.<br> For example, $P_{5703}(x) = 5x^3 + 7x^2 + 3$.</p> <p>We can see that:</p><ul><li>$P_n(0)$ is the last digit of $n$,</li> <li>$P_n(1)$ is the sum of the digits of $n$,</li> <li>$P_n(10)$ is $n$ itself.</li></ul><p>Define $Z(k)$ as the number of positive integers, $n$, not exceeding $k$ for which the polynomial $P_n$ has at least one integer root.</p> <p>It can be verified that $Z(100\,000)$ is $14696$.</p> <p>What is $Z(10^{16})$?</p>
https://projecteuler.net/problem=269
1311109198529286
270
A square piece of paper with integer dimensions $N \times N$ is placed with a corner at the origin and two of its sides along the $x$- and $y$-axes. Then, we cut it up respecting the following rules: - We only make straight cuts between two points lying on different sides of the square, and having integer coordinates. - Two cuts cannot cross, but several cuts can meet at the same border point. - Proceed until no more legal cuts can be made. Counting any reflections or rotations as distinct, we call $C(N)$ the number of ways to cut an $N \times N$ square. For example, $C(1) = 2$ and $C(2) = 30$ (shown below). What is $C(30) \bmod 10^8$?
<p>A square piece of paper with integer dimensions $N \times N$ is placed with a corner at the origin and two of its sides along the $x$- and $y$-axes. Then, we cut it up respecting the following rules: </p><ul><li>We only make straight cuts between two points lying on different sides of the square, and having integer coordinates.</li> <li>Two cuts cannot cross, but several cuts can meet at the same border point.</li> <li>Proceed until no more legal cuts can be made.</li> </ul><p>Counting any reflections or rotations as distinct, we call $C(N)$ the number of ways to cut an $N \times N$ square. For example, $C(1) = 2$ and $C(2) = 30$ (shown below).</p> <div align="center"><img src="resources/images/0270_CutSquare.gif?1678992056" alt="0270_CutSquare.gif"></div> <p>What is $C(30) \bmod 10^8$?</p>
https://projecteuler.net/problem=270
82282080
271
For a positive number $n$, define $S(n)$ as the sum of the integers $x$, for which $1 \lt x \lt n$ and $x^3 \equiv 1 \bmod n$. When $n=91$, there are $8$ possible values for $x$, namely: $9, 16, 22, 29, 53, 74, 79, 81$. Thus, $S(91)=9+16+22+29+53+74+79+81=363$. Find $S(13082761331670030)$.
<p> For a positive number $n$, define $S(n)$ as the sum of the integers $x$, for which $1 \lt x \lt n$ and<br>$x^3 \equiv 1 \bmod n$. </p> <p> When $n=91$, there are $8$ possible values for $x$, namely: $9, 16, 22, 29, 53, 74, 79, 81$.<br> Thus, $S(91)=9+16+22+29+53+74+79+81=363$.</p> <p> Find $S(13082761331670030)$. </p>
https://projecteuler.net/problem=271
4617456485273129588
272
For a positive number $n$, define $C(n)$ as the number of the integers $x$, for which $1 \lt x \lt n$ and $x^3 \equiv 1 \bmod n$. When $n=91$, there are $8$ possible values for $x$, namely: $9, 16, 22, 29, 53, 74, 79, 81$. Thus, $C(91)=8$. Find the sum of the positive numbers $n \le 10^{11}$ for which $C(n)=242$.
<p> For a positive number $n$, define $C(n)$ as the number of the integers $x$, for which $1 \lt x \lt n$ and<br>$x^3 \equiv 1 \bmod n$. </p> <p> When $n=91$, there are $8$ possible values for $x$, namely: $9, 16, 22, 29, 53, 74, 79, 81$.<br> Thus, $C(91)=8$.</p> <p> Find the sum of the positive numbers $n \le 10^{11}$ for which $C(n)=242$.</p>
https://projecteuler.net/problem=272
8495585919506151122
273
Consider equations of the form: $a^2 + b^2 = N$, $0 \le a \le b$, $a$, $b$ and $N$ integer. For $N=65$ there are two solutions: $a=1$, $b=8$ and $a=4$, $b=7$. We call $S(N)$ the sum of the values of $a$ of all solutions of $a^2 + b^2 = N$, $0 \le a \le b$, $a$, $b$ and $N$ integer. Thus $S(65) = 1 + 4 = 5$. Find $\sum S(N)$, for all squarefree $N$ only divisible by primes of the form $4k+1$ with $4k+1 \lt 150$.
<p>Consider equations of the form: $a^2 + b^2 = N$, $0 \le a \le b$, $a$, $b$ and $N$ integer.</p> <p>For $N=65$ there are two solutions:</p> <p>$a=1$, $b=8$ and $a=4$, $b=7$.</p> <p>We call $S(N)$ the sum of the values of $a$ of all solutions of $a^2 + b^2 = N$, $0 \le a \le b$, $a$, $b$ and $N$ integer.</p> <p>Thus $S(65) = 1 + 4 = 5$.</p> <p>Find $\sum S(N)$, for all squarefree $N$ only divisible by primes of the form $4k+1$ with $4k+1 \lt 150$.</p>
https://projecteuler.net/problem=273
2032447591196869022
274
For each integer $p \gt 1$ coprime to $10$ there is a positive divisibility multiplier $m \lt p$ which preserves divisibility by $p$ for the following function on any positive integer, $n$: $f(n) = (\text{all but the last digit of }n) + (\text{the last digit of }n) \cdot m$. That is, if $m$ is the divisibility multiplier for $p$, then $f(n)$ is divisible by $p$ if and only if $n$ is divisible by $p$. (When $n$ is much larger than $p$, $f(n)$ will be less than $n$ and repeated application of $f$ provides a multiplicative divisibility test for $p$.) For example, the divisibility multiplier for $113$ is $34$. $f(76275) = 7627 + 5 \cdot 34 = 7797$: $76275$ and $7797$ are both divisible by $113$. $f(12345) = 1234 + 5 \cdot 34 = 1404$: $12345$ and $1404$ are both not divisible by $113$. The sum of the divisibility multipliers for the primes that are coprime to $10$ and less than $1000$ is $39517$. What is the sum of the divisibility multipliers for the primes that are coprime to $10$ and less than $10^7$?
<p>For each integer $p \gt 1$ coprime to $10$ there is a positive <dfn>divisibility multiplier</dfn> $m \lt p$ which preserves divisibility by $p$ for the following function on any positive integer, $n$:</p> <p>$f(n) = (\text{all but the last digit of }n) + (\text{the last digit of }n) \cdot m$.</p> <p>That is, if $m$ is the divisibility multiplier for $p$, then $f(n)$ is divisible by $p$ if and only if $n$ is divisible by $p$.</p> <p>(When $n$ is much larger than $p$, $f(n)$ will be less than $n$ and repeated application of $f$ provides a multiplicative divisibility test for $p$.)</p> <p>For example, the divisibility multiplier for $113$ is $34$.</p> <p>$f(76275) = 7627 + 5 \cdot 34 = 7797$: $76275$ and $7797$ are both divisible by $113$.<br>$f(12345) = 1234 + 5 \cdot 34 = 1404$: $12345$ and $1404$ are both not divisible by $113$.</p> <p>The sum of the divisibility multipliers for the primes that are coprime to $10$ and less than $1000$ is $39517$. What is the sum of the divisibility multipliers for the primes that are coprime to $10$ and less than $10^7$?</p>
https://projecteuler.net/problem=274
1601912348822
275
Let us define a balanced sculpture of order $n$ as follows: - A polyominoAn arrangement of identical squares connected through shared edges; holes are allowed. made up of $n + 1$ tiles known as the blocks ($n$ tiles) and the plinth (remaining tile); - the plinth has its centre at position ($x = 0, y = 0$); - the blocks have $y$-coordinates greater than zero (so the plinth is the unique lowest tile); - the centre of mass of all the blocks, combined, has $x$-coordinate equal to zero. When counting the sculptures, any arrangements which are simply reflections about the $y$-axis, are not counted as distinct. For example, the $18$ balanced sculptures of order $6$ are shown below; note that each pair of mirror images (about the $y$-axis) is counted as one sculpture: There are $964$ balanced sculptures of order $10$ and $360505$ of order $15$. How many balanced sculptures are there of order $18$?
<p>Let us define a <dfn>balanced sculpture</dfn> of order $n$ as follows: </p><ul><li>A <strong class="tooltip">polyomino<span class="tooltiptext">An arrangement of identical squares connected through shared edges; holes are allowed.</span></strong> made up of $n + 1$ tiles known as the <dfn>blocks</dfn> ($n$ tiles)<br> and the <dfn>plinth</dfn> (remaining tile);</li> <li>the plinth has its centre at position ($x = 0, y = 0$);</li> <li>the blocks have $y$-coordinates greater than zero (so the plinth is the unique lowest tile);</li> <li>the centre of mass of all the blocks, combined, has $x$-coordinate equal to zero.</li> </ul><p>When counting the sculptures, any arrangements which are simply reflections about the $y$-axis, are <u>not</u> counted as distinct. For example, the $18$ balanced sculptures of order $6$ are shown below; note that each pair of mirror images (about the $y$-axis) is counted as one sculpture:</p> <div align="center"><img src="resources/images/0275_sculptures2.gif?1678992056" alt="0275_sculptures2.gif"></div> <p>There are $964$ balanced sculptures of order $10$ and $360505$ of order $15$.<br>How many balanced sculptures are there of order $18$?</p>
https://projecteuler.net/problem=275
15030564
276
Consider the triangles with integer sides $a$, $b$ and $c$ with $a \le b \le c$. An integer sided triangle $(a,b,c)$ is called primitive if $\gcd(a, b, c)$$\gcd(a,b,c)=\gcd(a,\gcd(b,c))$$=1$. How many primitive integer sided triangles exist with a perimeter not exceeding $10\,000\,000$?
<p>Consider the triangles with integer sides $a$, $b$ and $c$ with $a \le b \le c$.<br> An integer sided triangle $(a,b,c)$ is called primitive if <strong class="tooltip">$\gcd(a, b, c)$<span class="tooltiptext">$\gcd(a,b,c)=\gcd(a,\gcd(b,c))$</span></strong>$=1$. <br> How many primitive integer sided triangles exist with a perimeter not exceeding $10\,000\,000$? </p>
https://projecteuler.net/problem=276
5777137137739632912
277
A modified Collatz sequence of integers is obtained from a starting value $a_1$ in the following way: $a_{n+1} = \, \,\, \frac {a_n} 3 \quad$ if $a_n$ is divisible by $3$. We shall denote this as a large downward step, "D". $a_{n+1} = \frac {4 a_n+2} 3 \, \,$ if $a_n$ divided by $3$ gives a remainder of $1$. We shall denote this as an upward step, "U". $a_{n+1} = \frac {2 a_n -1} 3 \, \,$ if $a_n$ divided by $3$ gives a remainder of $2$. We shall denote this as a small downward step, "d". The sequence terminates when some $a_n = 1$. Given any integer, we can list out the sequence of steps. For instance if $a_1=231$, then the sequence $\{a_n\}=\{231,77,51,17,11,7,10,14,9,3,1\}$ corresponds to the steps "DdDddUUdDD". Of course, there are other sequences that begin with that same sequence "DdDddUUdDD....". For instance, if $a_1=1004064$, then the sequence is DdDddUUdDDDdUDUUUdDdUUDDDUdDD. In fact, $1004064$ is the smallest possible $a_1 > 10^6$ that begins with the sequence DdDddUUdDD. What is the smallest $a_1 > 10^{15}$ that begins with the sequence "UDDDUdddDDUDDddDdDddDDUDDdUUDd"?
<p> A modified Collatz sequence of integers is obtained from a starting value $a_1$ in the following way:</p> <p> $a_{n+1} = \, \,\, \frac {a_n} 3 \quad$ if $a_n$ is divisible by $3$. We shall denote this as a large downward step, "D".</p> <p> $a_{n+1} = \frac {4 a_n+2} 3 \, \,$ if $a_n$ divided by $3$ gives a remainder of $1$. We shall denote this as an upward step, "U". </p> <p> $a_{n+1} = \frac {2 a_n -1} 3 \, \,$ if $a_n$ divided by $3$ gives a remainder of $2$. We shall denote this as a small downward step, "d". </p> <p> The sequence terminates when some $a_n = 1$. </p> <p> Given any integer, we can list out the sequence of steps.<br> For instance if $a_1=231$, then the sequence $\{a_n\}=\{231,77,51,17,11,7,10,14,9,3,1\}$ corresponds to the steps "DdDddUUdDD". </p> <p> Of course, there are other sequences that begin with that same sequence "DdDddUUdDD....".<br> For instance, if $a_1=1004064$, then the sequence is DdDddUUdDDDdUDUUUdDdUUDDDUdDD.<br> In fact, $1004064$ is the smallest possible $a_1 &gt; 10^6$ that begins with the sequence DdDddUUdDD. </p> <p> What is the smallest $a_1 &gt; 10^{15}$ that begins with the sequence "UDDDUdddDDUDDddDdDddDDUDDdUUDd"? </p>
https://projecteuler.net/problem=277
1125977393124310
278
Given the values of integers $1 < a_1 < a_2 < \dots < a_n$, consider the linear combination $q_1 a_1+q_2 a_2 + \dots + q_n a_n=b$, using only integer values $q_k \ge 0$. Note that for a given set of $a_k$, it may be that not all values of $b$ are possible. For instance, if $a_1=5$ and $a_2=7$, there are no $q_1 \ge 0$ and $q_2 \ge 0$ such that $b$ could be $1, 2, 3, 4, 6, 8, 9, 11, 13, 16, 18$ or $23$. In fact, $23$ is the largest impossible value of $b$ for $a_1=5$ and $a_2=7$. We therefore call $f(5, 7) = 23$. Similarly, it can be shown that $f(6, 10, 15)=29$ and $f(14, 22, 77) = 195$. Find $\displaystyle \sum f( p\, q,p \, r, q \, r)$, where $p$, $q$ and $r$ are prime numbers and $p < q < r < 5000$.
<p> Given the values of integers $1 &lt; a_1 &lt; a_2 &lt; \dots &lt; a_n$, consider the linear combination<br> $q_1 a_1+q_2 a_2 + \dots + q_n a_n=b$, using only integer values $q_k \ge 0$. </p> <p> Note that for a given set of $a_k$, it may be that not all values of $b$ are possible.<br> For instance, if $a_1=5$ and $a_2=7$, there are no $q_1 \ge 0$ and $q_2 \ge 0$ such that $b$ could be<br> $1, 2, 3, 4, 6, 8, 9, 11, 13, 16, 18$ or $23$. <br> In fact, $23$ is the largest impossible value of $b$ for $a_1=5$ and $a_2=7$.<br> We therefore call $f(5, 7) = 23$.<br> Similarly, it can be shown that $f(6, 10, 15)=29$ and $f(14, 22, 77) = 195$. </p> <p> Find $\displaystyle \sum f( p\, q,p \, r, q \, r)$, where $p$, $q$ and $r$ are prime numbers and $p &lt; q &lt; r &lt; 5000$. </p>
https://projecteuler.net/problem=278
1228215747273908452
279
How many triangles are there with integral sides, at least one integral angle (measured in degrees), and a perimeter that does not exceed $10^8$?
<p> How many triangles are there with integral sides, at least one integral angle (measured in degrees), and a perimeter that does not exceed $10^8$? </p>
https://projecteuler.net/problem=279
416577688
280
A laborious ant walks randomly on a $5 \times 5$ grid. The walk starts from the central square. At each step, the ant moves to an adjacent square at random, without leaving the grid; thus there are $2$, $3$ or $4$ possible moves at each step depending on the ant's position. At the start of the walk, a seed is placed on each square of the lower row. When the ant isn't carrying a seed and reaches a square of the lower row containing a seed, it will start to carry the seed. The ant will drop the seed on the first empty square of the upper row it eventually reaches. What's the expected number of steps until all seeds have been dropped in the top row? Give your answer rounded to $6$ decimal places.
<p>A laborious ant walks randomly on a $5 \times 5$ grid. The walk starts from the central square. At each step, the ant moves to an adjacent square at random, without leaving the grid; thus there are $2$, $3$ or $4$ possible moves at each step depending on the ant's position.</p> <p>At the start of the walk, a seed is placed on each square of the lower row. When the ant isn't carrying a seed and reaches a square of the lower row containing a seed, it will start to carry the seed. The ant will drop the seed on the first empty square of the upper row it eventually reaches.</p> <p>What's the expected number of steps until all seeds have been dropped in the top row? <br> Give your answer rounded to $6$ decimal places.</p>
https://projecteuler.net/problem=280
430.088247
281
You are given a pizza (perfect circle) that has been cut into $m \cdot n$ equal pieces and you want to have exactly one topping on each slice. Let $f(m, n)$ denote the number of ways you can have toppings on the pizza with $m$ different toppings ($m \ge 2$), using each topping on exactly $n$ slices ($n \ge 1$). Reflections are considered distinct, rotations are not. Thus, for instance, $f(2,1) = 1$, $f(2, 2) = f(3, 1) = 2$ and $f(3, 2) = 16$. $f(3, 2)$ is shown below: Find the sum of all $f(m, n)$ such that $f(m, n) \le 10^{15}$.
<p>You are given a pizza (perfect circle) that has been cut into $m \cdot n$ equal pieces and you want to have exactly one topping on each slice.</p> <p>Let $f(m, n)$ denote the number of ways you can have toppings on the pizza with $m$ different toppings ($m \ge 2$), using each topping on exactly $n$ slices ($n \ge 1$).<br>Reflections are considered distinct, rotations are not. </p> <p>Thus, for instance, $f(2,1) = 1$, $f(2, 2) = f(3, 1) = 2$ and $f(3, 2) = 16$. <br>$f(3, 2)$ is shown below:</p> <div align="center"><img src="resources/images/0281_pizza.gif?1678992056" class="dark_img" alt="0281_pizza.gif"></div> <p>Find the sum of all $f(m, n)$ such that $f(m, n) \le 10^{15}$.</p>
https://projecteuler.net/problem=281
1485776387445623
282
$\def\htmltext#1{\style{font-family:inherit;}{\text{#1}}}$ For non-negative integers $m$, $n$, the Ackermann function $A(m,n)$ is defined as follows: $$ A(m,n) = \cases{ n+1 &$\htmltext{ if }m=0$\cr A(m-1,1) &$\htmltext{ if }m>0 \htmltext{ and } n=0$\cr A(m-1,A(m,n-1)) &$\htmltext{ if }m>0 \htmltext{ and } n>0$\cr }$$ For example $A(1,0) = 2$, $A(2,2) = 7$ and $A(3,4) = 125$. Find $\displaystyle\sum_{n=0}^6 A(n,n)$ and give your answer mod $14^8$.
$\def\htmltext#1{\style{font-family:inherit;}{\text{#1}}}$ <p> For non-negative integers $m$, $n$, the Ackermann function $A(m,n)$ is defined as follows: $$ A(m,n) = \cases{ n+1 &amp;$\htmltext{ if }m=0$\cr A(m-1,1) &amp;$\htmltext{ if }m&gt;0 \htmltext{ and } n=0$\cr A(m-1,A(m,n-1)) &amp;$\htmltext{ if }m&gt;0 \htmltext{ and } n&gt;0$\cr }$$ </p> <p> For example $A(1,0) = 2$, $A(2,2) = 7$ and $A(3,4) = 125$. </p> <p> Find $\displaystyle\sum_{n=0}^6 A(n,n)$ and give your answer mod $14^8$.</p>
https://projecteuler.net/problem=282
1098988351
283
Consider the triangle with sides $6$, $8$, and $10$. It can be seen that the perimeter and the area are both equal to $24$. So the area/perimeter ratio is equal to $1$. Consider also the triangle with sides $13$, $14$ and $15$. The perimeter equals $42$ while the area is equal to $84$. So for this triangle the area/perimeter ratio is equal to $2$. Find the sum of the perimeters of all integer sided triangles for which the area/perimeter ratios are equal to positive integers not exceeding $1000$.
<p> Consider the triangle with sides $6$, $8$, and $10$. It can be seen that the perimeter and the area are both equal to $24$. So the area/perimeter ratio is equal to $1$.<br> Consider also the triangle with sides $13$, $14$ and $15$. The perimeter equals $42$ while the area is equal to $84$. So for this triangle the area/perimeter ratio is equal to $2$. </p> <p> Find the sum of the perimeters of all integer sided triangles for which the area/perimeter ratios are equal to positive integers not exceeding $1000$. </p>
https://projecteuler.net/problem=283
28038042525570324
284
The 3-digit number 376 in the decimal numbering system is an example of numbers with the special property that its square ends with the same digits: 3762 = 141376. Let's call a number with this property a steady square. Steady squares can also be observed in other numbering systems. In the base 14 numbering system, the 3-digit number c37 is also a steady square: c372 = aa0c37, and the sum of its digits is c+3+7=18 in the same numbering system. The letters a, b, c and d are used for the 10, 11, 12 and 13 digits respectively, in a manner similar to the hexadecimal numbering system. For 1 ≤ n ≤ 9, the sum of the digits of all the n-digit steady squares in the base 14 numbering system is 2d8 (582 decimal). Steady squares with leading 0's are not allowed. Find the sum of the digits of all the n-digit steady squares in the base 14 numbering system for 1 ≤ n ≤ 10000 (decimal) and give your answer in the base 14 system using lower case letters where necessary.
<p>The 3-digit number 376 in the decimal numbering system is an example of numbers with the special property that its square ends with the same digits: 376<sup>2</sup> = 141376. Let's call a number with this property a steady square.</p> <p>Steady squares can also be observed in other numbering systems. In the base 14 numbering system, the 3-digit number c37 is also a steady square: c37<sup>2</sup> = aa0c37, and the sum of its digits is c+3+7=18 in the same numbering system. The letters a, b, c and d are used for the 10, 11, 12 and 13 digits respectively, in a manner similar to the hexadecimal numbering system.</p> <p>For 1 ≤ n ≤ 9, the sum of the digits of all the n-digit steady squares in the base 14 numbering system is 2d8 (582 decimal). Steady squares with leading 0's are not allowed.</p> <p>Find the sum of the digits of all the n-digit steady squares in the base 14 numbering system for<br> 1 ≤ n ≤ 10000 (decimal) and give your answer in the base 14 system using lower case letters where necessary.</p>
https://projecteuler.net/problem=284
5a411d7b
285
Albert chooses a positive integer $k$, then two real numbers $a, b$ are randomly chosen in the interval $[0,1]$ with uniform distribution. The square root of the sum $(k \cdot a + 1)^2 + (k \cdot b + 1)^2$ is then computed and rounded to the nearest integer. If the result is equal to $k$, he scores $k$ points; otherwise he scores nothing. For example, if $k = 6$, $a = 0.2$ and $b = 0.85$, then $(k \cdot a + 1)^2 + (k \cdot b + 1)^2 = 42.05$. The square root of $42.05$ is $6.484\cdots$ and when rounded to the nearest integer, it becomes $6$. This is equal to $k$, so he scores $6$ points. It can be shown that if he plays $10$ turns with $k = 1, k = 2, \dots, k = 10$, the expected value of his total score, rounded to five decimal places, is $10.20914$. If he plays $10^5$ turns with $k = 1, k = 2, k = 3, \dots, k = 10^5$, what is the expected value of his total score, rounded to five decimal places?
<p>Albert chooses a positive integer $k$, then two real numbers $a, b$ are randomly chosen in the interval $[0,1]$ with uniform distribution.<br> The square root of the sum $(k \cdot a + 1)^2 + (k \cdot b + 1)^2$ is then computed and rounded to the nearest integer. If the result is equal to $k$, he scores $k$ points; otherwise he scores nothing.</p> <p>For example, if $k = 6$, $a = 0.2$ and $b = 0.85$, then $(k \cdot a + 1)^2 + (k \cdot b + 1)^2 = 42.05$.<br> The square root of $42.05$ is $6.484\cdots$ and when rounded to the nearest integer, it becomes $6$.<br> This is equal to $k$, so he scores $6$ points.</p> <p>It can be shown that if he plays $10$ turns with $k = 1, k = 2, \dots, k = 10$, the expected value of his total score, rounded to five decimal places, is $10.20914$.</p> <p>If he plays $10^5$ turns with $k = 1, k = 2, k = 3, \dots, k = 10^5$, what is the expected value of his total score, rounded to five decimal places?</p>
https://projecteuler.net/problem=285
157055.80999
286
Barbara is a mathematician and a basketball player. She has found that the probability of scoring a point when shooting from a distance $x$ is exactly $(1 - x / q)$, where $q$ is a real constant greater than $50$. During each practice run, she takes shots from distances $x = 1, x = 2, \dots, x = 50$ and, according to her records, she has precisely a $2\%$ chance to score a total of exactly $20$ points. Find $q$ and give your answer rounded to $10$ decimal places.
<p>Barbara is a mathematician and a basketball player. She has found that the probability of scoring a point when shooting from a distance $x$ is exactly $(1 - x / q)$, where $q$ is a real constant greater than $50$.</p> <p>During each practice run, she takes shots from distances $x = 1, x = 2, \dots, x = 50$ and, according to her records, she has precisely a $2\%$ chance to score a total of exactly $20$ points.</p> <p>Find $q$ and give your answer rounded to $10$ decimal places.</p>
https://projecteuler.net/problem=286
52.6494571953
287
The quadtree encoding allows us to describe a $2^N \times 2^N$ black and white image as a sequence of bits (0 and 1). Those sequences are to be read from left to right like this: - the first bit deals with the complete $2^N \times 2^N$ region; - "0" denotes a split: the current $2^n \times 2^n$ region is divided into $4$ sub-regions of dimension $2^{n - 1} \times 2^{n - 1}$, the next bits contains the description of the top left, top right, bottom left and bottom right sub-regions - in that order; - "10" indicates that the current region contains only black pixels; - "11" indicates that the current region contains only white pixels. Consider the following $4 \times 4$ image (colored marks denote places where a split can occur): This image can be described by several sequences, for example : "001010101001011111011010101010", of length $30$, or "0100101111101110", of length $16$, which is the minimal sequence for this image. For a positive integer $N$, define $D_N$ as the $2^N \times 2^N$ image with the following coloring scheme: - the pixel with coordinates $x = 0, y = 0$ corresponds to the bottom left pixel, - if $(x - 2^{N - 1})^2 + (y - 2^{N - 1})^2 \le 2^{2N - 2}$ then the pixel is black, - otherwise the pixel is white. What is the length of the minimal sequence describing $D_{24}$?
<p>The quadtree encoding allows us to describe a $2^N \times 2^N$ black and white image as a sequence of bits (0 and 1). Those sequences are to be read from left to right like this: </p><ul><li>the first bit deals with the complete $2^N \times 2^N$ region;</li> <li>"0" denotes a split: <br>the current $2^n \times 2^n$ region is divided into $4$ sub-regions of dimension $2^{n - 1} \times 2^{n - 1}$,<br> the next bits contains the description of the top left, top right, bottom left and bottom right sub-regions - in that order;</li> <li>"10" indicates that the current region contains only black pixels;</li> <li>"11" indicates that the current region contains only white pixels.</li></ul><p>Consider the following $4 \times 4$ image (colored marks denote places where a split can occur):</p> <div class="center"><img src="resources/images/0287_quadtree.gif?1678992056" class="dark_img" alt="0287_quadtree.gif"></div> <p>This image can be described by several sequences, for example : "<span class="red strong">0</span><span class="blue strong">0</span>10101010<span class="green strong">0</span>1011111011<span class="orange strong">0</span>10101010", of length $30$, or<br> "<span class="red strong">0</span>10<span class="green strong"><b>0</b></span>101111101110", of length $16$, which is the minimal sequence for this image.</p> <p>For a positive integer $N$, define $D_N$ as the $2^N \times 2^N$ image with the following coloring scheme: </p><ul><li>the pixel with coordinates $x = 0, y = 0$ corresponds to the bottom left pixel,</li> <li>if $(x - 2^{N - 1})^2 + (y - 2^{N - 1})^2 \le 2^{2N - 2}$ then the pixel is black,</li> <li>otherwise the pixel is white.</li></ul><p>What is the length of the minimal sequence describing $D_{24}$?</p>
https://projecteuler.net/problem=287
313135496
288
For any prime $p$ the number $N(p, q)$ is defined by $N(p, q) = \sum_{n = 0}^q T_n \cdot p^n$ with $T_n$ generated by the following random number generator: $S_0 = 290797$ $S_{n + 1} = S_n^2 \bmod 50515093$ $T_n = S_n \bmod p$ Let $\operatorname{Nfac}(p, q)$ be the factorial of $N(p, q)$. Let $\operatorname{NF}(p, q)$ be the number of factors $p$ in $\operatorname{Nfac}(p, q)$. You are given that $\operatorname{NF}(3,10000) \bmod 3^{20} = 624955285$. Find $\operatorname{NF}(61, 10^7) \bmod 61^{10}$.
<p> For any prime $p$ the number $N(p, q)$ is defined by $N(p, q) = \sum_{n = 0}^q T_n \cdot p^n$<br> with $T_n$ generated by the following random number generator:</p> <p> $S_0 = 290797$<br> $S_{n + 1} = S_n^2 \bmod 50515093$<br> $T_n = S_n \bmod p$ </p> <p> Let $\operatorname{Nfac}(p, q)$ be the factorial of $N(p, q)$.<br> Let $\operatorname{NF}(p, q)$ be the number of factors $p$ in $\operatorname{Nfac}(p, q)$. </p> <p> You are given that $\operatorname{NF}(3,10000) \bmod 3^{20} = 624955285$. </p> <p> Find $\operatorname{NF}(61, 10^7) \bmod 61^{10}$.</p>
https://projecteuler.net/problem=288
605857431263981935
289
Let $C(x, y)$ be a circle passing through the points $(x, y)$, $(x, y + 1)$, $(x + 1, y)$ and $(x + 1, y + 1)$. For positive integers $m$ and $n$, let $E(m, n)$ be a configuration which consists of the $m \cdot n$ circles: $\{ C(x, y): 0 \le x \lt m, 0 \le y \lt n, x \text{ and } y \text{ are integers} \}$. An Eulerian cycle on $E(m, n)$ is a closed path that passes through each arc exactly once. Many such paths are possible on $E(m, n)$, but we are only interested in those which are not self-crossing: a non-crossing path just touches itself at lattice points, but it never crosses itself. The image below shows $E(3,3)$ and an example of an Eulerian non-crossing path. Let $L(m, n)$ be the number of Eulerian non-crossing paths on $E(m, n)$. For example, $L(1,2) = 2$, $L(2,2) = 37$ and $L(3,3) = 104290$. Find $L(6,10) \bmod 10^{10}$.
<p>Let $C(x, y)$ be a circle passing through the points $(x, y)$, $(x, y + 1)$, $(x + 1, y)$ and $(x + 1, y + 1)$.</p> <p>For positive integers $m$ and $n$, let $E(m, n)$ be a configuration which consists of the $m \cdot n$ circles:<br> $\{ C(x, y): 0 \le x \lt m, 0 \le y \lt n, x \text{ and } y \text{ are integers} \}$.</p> <p>An Eulerian cycle on $E(m, n)$ is a closed path that passes through each arc exactly once.<br> Many such paths are possible on $E(m, n)$, but we are only interested in those which are not self-crossing: a non-crossing path just touches itself at lattice points, but it never crosses itself.</p> <p>The image below shows $E(3,3)$ and an example of an Eulerian non-crossing path.<br></p><div align="center"><img src="resources/images/0289_euler.gif?1678992056" alt="0289_euler.gif"></div> <p>Let $L(m, n)$ be the number of Eulerian non-crossing paths on $E(m, n)$.<br> For example, $L(1,2) = 2$, $L(2,2) = 37$ and $L(3,3) = 104290$.</p> <p>Find $L(6,10) \bmod 10^{10}$.</p>
https://projecteuler.net/problem=289
6567944538
290
How many integers $0 \le n \lt 10^{18}$ have the property that the sum of the digits of $n$ equals the sum of digits of $137n$?
<p> How many integers $0 \le n \lt 10^{18}$ have the property that the sum of the digits of $n$ equals the sum of digits of $137n$? </p>
https://projecteuler.net/problem=290
20444710234716473
291
A prime number $p$ is called a Panaitopol prime if $p = \dfrac{x^4 - y^4}{x^3 + y^3}$ for some positive integers $x$ and $y$. Find how many Panaitopol primes are less than $5 \times 10^{15}$.
<p> A prime number $p$ is called a Panaitopol prime if $p = \dfrac{x^4 - y^4}{x^3 + y^3}$ for some positive integers $x$ and $y$.</p> <p> Find how many Panaitopol primes are less than $5 \times 10^{15}$. </p>
https://projecteuler.net/problem=291
4037526
292
We shall define a pythagorean polygon to be a convex polygon with the following properties: - there are at least three vertices, - no three vertices are aligned, - each vertex has integer coordinates, - each edge has integer length. For a given integer $n$, define $P(n)$ as the number of distinct pythagorean polygons for which the perimeter is $\le n$. Pythagorean polygons should be considered distinct as long as none is a translation of another. You are given that $P(4) = 1$, $P(30) = 3655$ and $P(60) = 891045$. Find $P(120)$.
<p>We shall define a <dfn>pythagorean polygon</dfn> to be a <strong>convex polygon</strong> with the following properties:<br></p><ul><li>there are at least three vertices,</li> <li>no three vertices are aligned,</li> <li>each vertex has <b>integer coordinates</b>,</li> <li>each edge has <b>integer length</b>.</li></ul><p>For a given integer $n$, define $P(n)$ as the number of distinct pythagorean polygons for which the perimeter is $\le n$.<br> Pythagorean polygons should be considered distinct as long as none is a translation of another.</p> <p>You are given that $P(4) = 1$, $P(30) = 3655$ and $P(60) = 891045$.<br> Find $P(120)$.</p>
https://projecteuler.net/problem=292
3600060866
293
An even positive integer $N$ will be called admissible, if it is a power of $2$ or its distinct prime factors are consecutive primes. The first twelve admissible numbers are $2,4,6,8,12,16,18,24,30,32,36,48$. If $N$ is admissible, the smallest integer $M \gt 1$ such that $N+M$ is prime, will be called the pseudo-Fortunate number for $N$. For example, $N=630$ is admissible since it is even and its distinct prime factors are the consecutive primes $2,3,5$ and $7$. The next prime number after $631$ is $641$; hence, the pseudo-Fortunate number for $630$ is $M=11$. It can also be seen that the pseudo-Fortunate number for $16$ is $3$. Find the sum of all distinct pseudo-Fortunate numbers for admissible numbers $N$ less than $10^9$.
<p> An even positive integer $N$ will be called admissible, if it is a power of $2$ or its distinct prime factors are consecutive primes.<br> The first twelve admissible numbers are $2,4,6,8,12,16,18,24,30,32,36,48$. </p> <p> If $N$ is admissible, the smallest integer $M \gt 1$ such that $N+M$ is prime, will be called the pseudo-Fortunate number for $N$. </p> <p> For example, $N=630$ is admissible since it is even and its distinct prime factors are the consecutive primes $2,3,5$ and $7$.<br> The next prime number after $631$ is $641$; hence, the pseudo-Fortunate number for $630$ is $M=11$.<br> It can also be seen that the pseudo-Fortunate number for $16$ is $3$. </p> <p> Find the sum of all distinct pseudo-Fortunate numbers for admissible numbers $N$ less than $10^9$. </p>
https://projecteuler.net/problem=293
2209
294
For a positive integer $k$, define $d(k)$ as the sum of the digits of $k$ in its usual decimal representation. Thus $d(42) = 4+2 = 6$. For a positive integer $n$, define $S(n)$ as the number of positive integers $k \lt 10^n$ with the following properties : - $k$ is divisible by $23$ and - $d(k) = 23$. You are given that $S(9) = 263626$ and $S(42) = 6377168878570056$. Find $S(11^{12})$ and give your answer mod $10^9$.
<p> For a positive integer $k$, define $d(k)$ as the sum of the digits of $k$ in its usual decimal representation. Thus $d(42) = 4+2 = 6$. </p> <p> For a positive integer $n$, define $S(n)$ as the number of positive integers $k \lt 10^n$ with the following properties : </p><ul><li>$k$ is divisible by $23$ and </li><li>$d(k) = 23$. </li></ul> You are given that $S(9) = 263626$ and $S(42) = 6377168878570056$. <p> Find $S(11^{12})$ and give your answer mod $10^9$. </p>
https://projecteuler.net/problem=294
789184709
295
We call the convex area enclosed by two circles a lenticular hole if: - The centres of both circles are on lattice points. - The two circles intersect at two distinct lattice points. - The interior of the convex area enclosed by both circles does not contain any lattice points. Consider the circles: $C_0$: $x^2 + y^2 = 25$ $C_1$: $(x + 4)^2 + (y - 4)^2 = 1$ $C_2$: $(x - 12)^2 + (y - 4)^2 = 65$ The circles $C_0$, $C_1$ and $C_2$ are drawn in the picture below. $C_0$ and $C_1$ form a lenticular hole, as well as $C_0$ and $C_2$. We call an ordered pair of positive real numbers $(r_1, r_2)$ a lenticular pair if there exist two circles with radii $r_1$ and $r_2$ that form a lenticular hole. We can verify that $(1, 5)$ and $(5, \sqrt{65})$ are the lenticular pairs of the example above. Let $L(N)$ be the number of distinct lenticular pairs $(r_1, r_2)$ for which $0 \lt r_1 \le r_2 \le N$. We can verify that $L(10) = 30$ and $L(100) = 3442$. Find $L(100\,000)$.
<p>We call the convex area enclosed by two circles a <dfn>lenticular hole</dfn> if: </p><ul><li>The centres of both circles are on lattice points.</li> <li>The two circles intersect at two distinct lattice points.</li> <li>The interior of the convex area enclosed by both circles does not contain any lattice points. </li> </ul><p>Consider the circles:<br> $C_0$: $x^2 + y^2 = 25$<br> $C_1$: $(x + 4)^2 + (y - 4)^2 = 1$<br> $C_2$: $(x - 12)^2 + (y - 4)^2 = 65$ </p> <p> The circles $C_0$, $C_1$ and $C_2$ are drawn in the picture below.</p> <div align="center"><img src="resources/images/0295_lenticular.gif?1678992056" alt="0295_lenticular.gif"></div> <p> $C_0$ and $C_1$ form a lenticular hole, as well as $C_0$ and $C_2$.</p> <p> We call an ordered pair of positive real numbers $(r_1, r_2)$ a <dfn>lenticular pair</dfn> if there exist two circles with radii $r_1$ and $r_2$ that form a lenticular hole. We can verify that $(1, 5)$ and $(5, \sqrt{65})$ are the lenticular pairs of the example above.</p> <p> Let $L(N)$ be the number of <b>distinct</b> lenticular pairs $(r_1, r_2)$ for which $0 \lt r_1 \le r_2 \le N$.<br> We can verify that $L(10) = 30$ and $L(100) = 3442$.</p> <p> Find $L(100\,000)$. </p>
https://projecteuler.net/problem=295
4884650818
296
Given is an integer sided triangle $ABC$ with $BC \le AC \le AB$. $k$ is the angular bisector of angle $ACB$. $m$ is the tangent at $C$ to the circumscribed circle of $ABC$. $n$ is a line parallel to $m$ through $B$. The intersection of $n$ and $k$ is called $E$. How many triangles $ABC$ with a perimeter not exceeding $100\,000$ exist such that $BE$ has integral length?
<p> Given is an integer sided triangle $ABC$ with $BC \le AC \le AB$.<br>$k$ is the angular bisector of angle $ACB$.<br>$m$ is the tangent at $C$ to the circumscribed circle of $ABC$.<br>$n$ is a line parallel to $m$ through $B$.<br> The intersection of $n$ and $k$ is called $E$. </p> <div align="center"><img src="resources/images/0296_bisector.gif?1678992056" class="dark_img" alt="0296_bisector.gif"></div> <p> How many triangles $ABC$ with a perimeter not exceeding $100\,000$ exist such that $BE$ has integral length? </p>
https://projecteuler.net/problem=296
1137208419
297
Each new term in the Fibonacci sequence is generated by adding the previous two terms. Starting with $1$ and $2$, the first $10$ terms will be: $1, 2, 3, 5, 8, 13, 21, 34, 55, 89$. Every positive integer can be uniquely written as a sum of nonconsecutive terms of the Fibonacci sequence. For example, $100 = 3 + 8 + 89$. Such a sum is called the Zeckendorf representation of the number. For any integer $n \gt 0$, let $z(n)$ be the number of terms in the Zeckendorf representation of $n$. Thus, $z(5) = 1$, $z(14) = 2$, $z(100) = 3$ etc. Also, for $0 \lt n \lt 10^6$, $\sum z(n) = 7894453$. Find $\sum z(n)$ for $0 \lt n \lt 10^{17}$.
<p>Each new term in the Fibonacci sequence is generated by adding the previous two terms.<br> Starting with $1$ and $2$, the first $10$ terms will be: $1, 2, 3, 5, 8, 13, 21, 34, 55, 89$.</p> <p>Every positive integer can be uniquely written as a sum of nonconsecutive terms of the Fibonacci sequence. For example, $100 = 3 + 8 + 89$.<br> Such a sum is called the <strong>Zeckendorf representation</strong> of the number.</p> <p>For any integer $n \gt 0$, let $z(n)$ be the number of terms in the Zeckendorf representation of $n$.<br> Thus, $z(5) = 1$, $z(14) = 2$, $z(100) = 3$ etc.<br> Also, for $0 \lt n \lt 10^6$, $\sum z(n) = 7894453$.</p> <p>Find $\sum z(n)$ for $0 \lt n \lt 10^{17}$.</p>
https://projecteuler.net/problem=297
2252639041804718029
298
Larry and Robin play a memory game involving a sequence of random numbers between 1 and 10, inclusive, that are called out one at a time. Each player can remember up to 5 previous numbers. When the called number is in a player's memory, that player is awarded a point. If it's not, the player adds the called number to his memory, removing another number if his memory is full. Both players start with empty memories. Both players always add new missed numbers to their memory but use a different strategy in deciding which number to remove: Larry's strategy is to remove the number that hasn't been called in the longest time. Robin's strategy is to remove the number that's been in the memory the longest time. Example game: | Turn | Callednumber | Larry'smemory | Larry'sscore | Robin'smemory | Robin'sscore | | --- | --- | --- | --- | --- | --- | | 1 | 1 | 1 | 0 | 1 | 0 | | 2 | 2 | 1,2 | 0 | 1,2 | 0 | | 3 | 4 | 1,2,4 | 0 | 1,2,4 | 0 | | 4 | 6 | 1,2,4,6 | 0 | 1,2,4,6 | 0 | | 5 | 1 | 1,2,4,6 | 1 | 1,2,4,6 | 1 | | 6 | 8 | 1,2,4,6,8 | 1 | 1,2,4,6,8 | 1 | | 7 | 10 | 1,4,6,8,10 | 1 | 2,4,6,8,10 | 1 | | 8 | 2 | 1,2,6,8,10 | 1 | 2,4,6,8,10 | 2 | | 9 | 4 | 1,2,4,8,10 | 1 | 2,4,6,8,10 | 3 | | 10 | 1 | 1,2,4,8,10 | 2 | 1,4,6,8,10 | 3 | Denoting Larry's score by L and Robin's score by R, what is the expected value of |L-R| after 50 turns? Give your answer rounded to eight decimal places using the format x.xxxxxxxx .
<p>Larry and Robin play a memory game involving a sequence of random numbers between 1 and 10, inclusive, that are called out one at a time. Each player can remember up to 5 previous numbers. When the called number is in a player's memory, that player is awarded a point. If it's not, the player adds the called number to his memory, removing another number if his memory is full.</p> <p>Both players start with empty memories. Both players always add new missed numbers to their memory but use a different strategy in deciding which number to remove:<br> Larry's strategy is to remove the number that hasn't been called in the longest time.<br> Robin's strategy is to remove the number that's been in the memory the longest time.</p> <p>Example game:</p> <table class="grid center"> <tr> <th>Turn</th> <th>Called<br>number</th> <th class="right">Larry's<br>memory</th> <th>Larry's<br>score</th> <th class="right">Robin's<br>memory</th> <th>Robin's<br>score</th> </tr> <tr> <td>1</td> <td>1</td> <td class="right">1</td> <td>0</td> <td class="right">1</td> <td>0</td> </tr> <tr> <td>2</td> <td>2</td> <td class="right">1,2</td> <td>0</td> <td class="right">1,2</td> <td>0</td> </tr><tr><td>3</td> <td>4</td> <td class="right">1,2,4</td> <td>0</td> <td class="right">1,2,4</td> <td>0</td> </tr> <tr> <td>4</td> <td>6</td> <td class="right">1,2,4,6</td> <td>0</td> <td class="right">1,2,4,6</td> <td>0</td> </tr> <tr> <td>5</td> <td>1</td> <td class="right">1,2,4,6</td> <td>1</td> <td class="right">1,2,4,6</td> <td>1</td> </tr> <tr> <td>6</td> <td>8</td> <td class="right">1,2,4,6,8</td> <td>1</td> <td class="right">1,2,4,6,8</td> <td>1</td> </tr> <tr> <td>7</td> <td>10</td> <td class="right">1,4,6,8,10</td> <td>1</td> <td class="right">2,4,6,8,10</td> <td>1</td> </tr> <tr> <td>8</td> <td>2</td> <td class="right">1,2,6,8,10</td> <td>1</td> <td class="right">2,4,6,8,10</td> <td>2</td> </tr> <tr> <td>9</td> <td>4</td> <td class="right">1,2,4,8,10</td> <td>1</td> <td class="right">2,4,6,8,10</td> <td>3</td> </tr> <tr> <td>10</td> <td>1</td> <td class="right">1,2,4,8,10</td> <td>2</td> <td class="right">1,4,6,8,10</td> <td>3</td> </tr> </table> <p>Denoting Larry's score by <var>L</var> and Robin's score by <var>R</var>, what is the expected value of |<var>L</var>-<var>R</var>| after 50 turns? Give your answer rounded to eight decimal places using the format x.xxxxxxxx .</p>
https://projecteuler.net/problem=298
1.76882294
299
Four points with integer coordinates are selected: $A(a, 0)$, $B(b, 0)$, $C(0, c)$ and $D(0, d)$, with $0 \lt a \lt b$ and $0 \lt c \lt d$. Point $P$, also with integer coordinates, is chosen on the line $AC$ so that the three triangles $ABP$, $CDP$ and $BDP$ are all similarHave equal angles. It is easy to prove that the three triangles can be similar, only if $a = c$. So, given that $a = c$, we are looking for triplets $(a, b, d)$ such that at least one point $P$ (with integer coordinates) exists on $AC$, making the three triangles $ABP$, $CDP$ and $BDP$ all similar. For example, if $(a, b, d)=(2,3,4)$, it can be easily verified that point $P(1,1)$ satisfies the above condition. Note that the triplets $(2,3,4)$ and $(2,4,3)$ are considered as distinct, although point $P(1,1)$ is common for both. If $b + d \lt 100$, there are $92$ distinct triplets $(a, b, d)$ such that point $P$ exists. If $b + d \lt 100\,000$, there are $320471$ distinct triplets $(a, b, d)$ such that point $P$ exists. If $b + d \lt 100\,000\,000$, how many distinct triplets $(a, b, d)$ are there such that point $P$ exists?
<p>Four points with integer coordinates are selected:<br>$A(a, 0)$, $B(b, 0)$, $C(0, c)$ and $D(0, d)$, with $0 \lt a \lt b$ and $0 \lt c \lt d$.<br> Point $P$, also with integer coordinates, is chosen on the line $AC$ so that the three triangles $ABP$, $CDP$ and $BDP$ are all <dfn class="tooltip">similar<span class="tooltiptext">Have equal angles</span></dfn>.</p> <div align="center"><img src="resources/images/0299_ThreeSimTri.gif?1678992056" class="dark_img" alt="0299_ThreeSimTri.gif"></div> <p>It is easy to prove that the three triangles can be similar, only if $a = c$.</p> <p>So, given that $a = c$, we are looking for triplets $(a, b, d)$ such that at least one point $P$ (with integer coordinates) exists on $AC$, making the three triangles $ABP$, $CDP$ and $BDP$ all similar.</p> <p>For example, if $(a, b, d)=(2,3,4)$, it can be easily verified that point $P(1,1)$ satisfies the above condition. Note that the triplets $(2,3,4)$ and $(2,4,3)$ are considered as distinct, although point $P(1,1)$ is common for both.</p> <p>If $b + d \lt 100$, there are $92$ distinct triplets $(a, b, d)$ such that point $P$ exists.<br> If $b + d \lt 100\,000$, there are $320471$ distinct triplets $(a, b, d)$ such that point $P$ exists.</p> <p>If $b + d \lt 100\,000\,000$, how many distinct triplets $(a, b, d)$ are there such that point $P$ exists?</p>
https://projecteuler.net/problem=299
549936643
300
In a very simplified form, we can consider proteins as strings consisting of hydrophobic (H) and polar (P) elements, e.g. HHPPHHHPHHPH. For this problem, the orientation of a protein is important; e.g. HPP is considered distinct from PPH. Thus, there are $2^n$ distinct proteins consisting of $n$ elements. When one encounters these strings in nature, they are always folded in such a way that the number of H-H contact points is as large as possible, since this is energetically advantageous. As a result, the H-elements tend to accumulate in the inner part, with the P-elements on the outside. Natural proteins are folded in three dimensions of course, but we will only consider protein folding in two dimensions. The figure below shows two possible ways that our example protein could be folded (H-H contact points are shown with red dots). The folding on the left has only six H-H contact points, thus it would never occur naturally. On the other hand, the folding on the right has nine H-H contact points, which is optimal for this string. Assuming that H and P elements are equally likely to occur in any position along the string, the average number of H-H contact points in an optimal folding of a random protein string of length $8$ turns out to be $850 / 2^8 = 3.3203125$. What is the average number of H-H contact points in an optimal folding of a random protein string of length $15$? Give your answer using as many decimal places as necessary for an exact result.
<p>In a very simplified form, we can consider proteins as strings consisting of hydrophobic (H) and polar (P) elements, e.g. HHPPHHHPHHPH. <br> For this problem, the orientation of a protein is important; e.g. HPP is considered distinct from PPH. Thus, there are $2^n$ distinct proteins consisting of $n$ elements.</p> <p>When one encounters these strings in nature, they are always folded in such a way that the number of H-H contact points is as large as possible, since this is energetically advantageous.<br> As a result, the H-elements tend to accumulate in the inner part, with the P-elements on the outside.<br> Natural proteins are folded in three dimensions of course, but we will only consider protein folding in <u>two dimensions</u>.</p> <p>The figure below shows two possible ways that our example protein could be folded (H-H contact points are shown with red dots).</p> <div align="center"><img src="resources/images/0300_protein.gif?1678992056" alt="0300_protein.gif"></div> <p>The folding on the left has only six H-H contact points, thus it would never occur naturally.<br> On the other hand, the folding on the right has nine H-H contact points, which is optimal for this string.</p> <p>Assuming that H and P elements are equally likely to occur in any position along the string, the average number of H-H contact points in an optimal folding of a random protein string of length $8$ turns out to be $850 / 2^8 = 3.3203125$.</p> <p>What is the average number of H-H contact points in an optimal folding of a random protein string of length $15$?<br> Give your answer using as many decimal places as necessary for an exact result.</p>
https://projecteuler.net/problem=300
8.0540771484375