2018-09-30 22:01:58 +00:00
---
id: 5900f3b11000cf542c50fec4
title: 'Problem 69: Totient maximum'
2020-11-27 18:02:05 +00:00
challengeType: 5
2019-08-05 16:17:33 +00:00
forumTopicId: 302181
2021-01-13 02:31:00 +00:00
dashedName: problem-69-totient-maximum
2018-09-30 22:01:58 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
2020-02-07 08:47:35 +00:00
2020-11-27 18:02:05 +00:00
Euler's Totient function, φ(`n`) \[sometimes called the phi function], is used to determine the number of numbers less than `n` which are relatively prime to `n` . For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, φ(9)=6.
2020-02-07 08:47:35 +00:00
< div style = 'margin-left: 4em;' >
2020-11-27 18:02:05 +00:00
| < var > n< / var > | Relatively Prime | φ(< var > n< / var > ) | < var > n< / var > /φ(< var > n< / var > ) |
| ------------ | ---------------- | --------------- | ---------------------------- |
| 2 | 1 | 1 | 2 |
| 3 | 1,2 | 2 | 1.5 |
| 4 | 1,3 | 2 | 2 |
| 5 | 1,2,3,4 | 4 | 1.25 |
| 6 | 1,5 | 2 | 3 |
| 7 | 1,2,3,4,5,6 | 6 | 1.1666... |
| 8 | 1,3,5,7 | 4 | 2 |
| 9 | 1,2,4,5,7,8 | 6 | 1.5 |
| 10 | 1,3,7,9 | 4 | 2.5 |
2020-02-07 08:47:35 +00:00
< / div >
2020-11-27 18:02:05 +00:00
It can be seen that `n` =6 produces a maximum `n` /φ(`n`) for `n` ≤ 10.
2020-02-07 08:47:35 +00:00
2020-11-27 18:02:05 +00:00
Find the value of `n` ≤ 1,000,000 for which n/φ(`n`) is a maximum.
2020-02-07 08:47:35 +00:00
2020-11-27 18:02:05 +00:00
# --hints--
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
`totientMaximum()` should return a number.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert(typeof totientMaximum() === 'number');
```
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
`totientMaximum()` should return 510510.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert.strictEqual(totientMaximum(), 510510);
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
# --seed--
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
## --seed-contents--
2018-09-30 22:01:58 +00:00
```js
2020-02-28 12:39:47 +00:00
function totientMaximum() {
2020-09-15 16:57:40 +00:00
2018-09-30 22:01:58 +00:00
return true;
}
2020-02-28 12:39:47 +00:00
totientMaximum();
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
```js
// solution required
```