2018-09-30 23:01:58 +01:00
|
|
|
---
|
|
|
|
id: 5900f4c21000cf542c50ffd4
|
|
|
|
title: 'Problem 340: Crazy Function'
|
2020-11-27 19:02:05 +01:00
|
|
|
challengeType: 5
|
2019-08-05 09:17:33 -07:00
|
|
|
forumTopicId: 301999
|
2021-01-13 03:31:00 +01:00
|
|
|
dashedName: problem-340-crazy-function
|
2018-09-30 23:01:58 +01:00
|
|
|
---
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --description--
|
|
|
|
|
2021-07-29 20:59:06 +02:00
|
|
|
For fixed integers $a$, $b$, $c$, define the crazy function $F(n)$ as follows:
|
2020-11-27 19:02:05 +01:00
|
|
|
|
2021-07-29 20:59:06 +02:00
|
|
|
$$\begin{align}
|
|
|
|
& F(n) = n - c \\;\text{ for all } n > b \\\\
|
|
|
|
& F(n) = F(a + F(a + F(a + F(a + n)))) \\;\text{ for all } n ≤ b.
|
|
|
|
\end{align}$$
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2021-07-29 20:59:06 +02:00
|
|
|
Also, define $S(a, b, c) = \displaystyle\sum_{n = 0}^b F(n)$.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2021-07-29 20:59:06 +02:00
|
|
|
For example, if $a = 50$, $b = 2000$ and $c = 40$, then $F(0) = 3240$ and $F(2000) = 2040$. Also, $S(50, 2000, 40) = 5\\,204\\,240$.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2021-07-29 20:59:06 +02:00
|
|
|
Find the last 9 digits of $S({21}^7, 7^{21}, {12}^7)$.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --hints--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2021-07-29 20:59:06 +02:00
|
|
|
`crazyFunction()` should return `291504964`.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
2021-07-29 20:59:06 +02:00
|
|
|
assert.strictEqual(crazyFunction(), 291504964);
|
2018-09-30 23:01:58 +01:00
|
|
|
```
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --seed--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
## --seed-contents--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
```js
|
2021-07-29 20:59:06 +02:00
|
|
|
function crazyFunction() {
|
2020-09-15 09:57:40 -07:00
|
|
|
|
2018-09-30 23:01:58 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-07-29 20:59:06 +02:00
|
|
|
crazyFunction();
|
2018-09-30 23:01:58 +01:00
|
|
|
```
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --solutions--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
```js
|
|
|
|
// solution required
|
|
|
|
```
|