2018-10-10 22:03:03 +00:00
|
|
|
---
|
|
|
|
id: 5900f53a1000cf542c51004c
|
2021-02-06 04:42:36 +00:00
|
|
|
title: 'Problem 461: Almost Pi'
|
2018-10-10 22:03:03 +00:00
|
|
|
challengeType: 5
|
2021-02-06 04:42:36 +00:00
|
|
|
forumTopicId: 302136
|
2021-01-13 02:31:00 +00:00
|
|
|
dashedName: problem-461-almost-pi
|
2018-10-10 22:03:03 +00:00
|
|
|
---
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
# --description--
|
2018-10-10 22:03:03 +00:00
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
Let fn(k) = ek/n - 1, for all non-negative integers k.
|
|
|
|
|
|
|
|
Remarkably, f200(6) + f200(75) + f200(89) + f200(226) = 3.141592644529… ≈ π.
|
|
|
|
|
|
|
|
In fact, it is the best approximation of π of the form fn(a) + fn(b) + fn(c) + fn(d) for n = 200.
|
|
|
|
|
|
|
|
Let g(n) = a2 + b2 + c2 + d 2 for a, b, c, d that minimize the error: | fn(a) + fn(b) + fn(c) + fn(d) - π|
|
|
|
|
|
|
|
|
(where |x| denotes the absolute value of x).
|
|
|
|
|
|
|
|
You are given g(200) = 62 + 752 + 892 + 2262 = 64658.
|
|
|
|
|
|
|
|
Find g(10000).
|
2018-10-10 22:03:03 +00:00
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
# --hints--
|
2018-10-10 22:03:03 +00:00
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
`euler461()` should return 159820276.
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
```js
|
2020-12-16 07:37:30 +00:00
|
|
|
assert.strictEqual(euler461(), 159820276);
|
2018-10-10 22:03:03 +00:00
|
|
|
```
|
|
|
|
|
2021-01-13 02:31:00 +00:00
|
|
|
# --seed--
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
```js
|
|
|
|
function euler461() {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
euler461();
|
|
|
|
```
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
# --solutions--
|
2020-08-13 15:24:35 +00:00
|
|
|
|
2021-01-13 02:31:00 +00:00
|
|
|
```js
|
|
|
|
// solution required
|
|
|
|
```
|