fix(curriculum): clean-up Project Euler 201-220 (#42826)
* fix: clean-up Project Euler 201-220 * fix: corrections from review Co-authored-by: Tom <20648924+moT01@users.noreply.github.com> Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
This commit is contained in:
@ -8,24 +8,31 @@ dashedName: problem-214-totient-chains
|
||||
|
||||
# --description--
|
||||
|
||||
Let φ be Euler's totient function, i.e. for a natural number n,
|
||||
Let $φ$ be Euler's totient function, i.e. for a natural number $n$, $φ(n)$ is the number of $k$, $1 ≤ k ≤ n$, for which $gcd(k,n) = 1$.
|
||||
|
||||
φ(n) is the number of k, 1 ≤ k ≤ n, for which gcd(k,n) = 1.
|
||||
By iterating $φ$, 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:
|
||||
|
||||
By iterating φ, 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:
|
||||
|
||||
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
|
||||
$$\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?
|
||||
What is the sum of all primes less than $40\\,000\\,000$ which generate a chain of length 25?
|
||||
|
||||
# --hints--
|
||||
|
||||
`euler214()` should return 1677366278943.
|
||||
`totientChains()` should return `1677366278943`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(euler214(), 1677366278943);
|
||||
assert.strictEqual(totientChains(), 1677366278943);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
@ -33,12 +40,12 @@ assert.strictEqual(euler214(), 1677366278943);
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function euler214() {
|
||||
function totientChains() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
euler214();
|
||||
totientChains();
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
Reference in New Issue
Block a user