2018-09-30 22:01:58 +00:00
|
|
|
---
|
|
|
|
id: 5900f4c21000cf542c50ffd4
|
|
|
|
title: 'Problem 340: Crazy Function'
|
2020-11-27 18:02:05 +00:00
|
|
|
challengeType: 5
|
2019-08-05 16:17:33 +00:00
|
|
|
forumTopicId: 301999
|
2021-01-13 02:31:00 +00:00
|
|
|
dashedName: problem-340-crazy-function
|
2018-09-30 22:01:58 +00:00
|
|
|
---
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --description--
|
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
For fixed integers a, b, c, define the crazy function F(n) as follows:
|
2020-11-27 18:02:05 +00:00
|
|
|
|
2018-10-08 00:01:53 +00:00
|
|
|
F(n) = n - c for all n > b
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
F(n) = F(a + F(a + F(a + F(a + n)))) for all n ≤ b.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
|
|
Also, define S(a, b, c) = .
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
For example, if a = 50, b = 2000 and c = 40, then F(0) = 3240 and F(2000) = 2040. Also, S(50, 2000, 40) = 5204240.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
|
|
Find the last 9 digits of S(217, 721, 127).
|
|
|
|
|
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
|
|
|
`euler340()` should return 291504964.
|
2018-09-30 22:01:58 +00:00
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
```js
|
|
|
|
assert.strictEqual(euler340(), 291504964);
|
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
|
|
|
|
function euler340() {
|
2020-09-15 16:57:40 +00:00
|
|
|
|
2018-09-30 22:01:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
euler340();
|
|
|
|
```
|
|
|
|
|
2020-11-27 18:02:05 +00:00
|
|
|
# --solutions--
|
2018-09-30 22:01:58 +00:00
|
|
|
|
|
|
|
```js
|
|
|
|
// solution required
|
|
|
|
```
|