2018-09-30 23:01:58 +01:00
|
|
|
---
|
|
|
|
id: 5900f53c1000cf542c51004e
|
|
|
|
title: 'Problem 463: A weird recurrence relation'
|
2020-11-27 19:02:05 +01:00
|
|
|
challengeType: 5
|
2019-08-05 09:17:33 -07:00
|
|
|
forumTopicId: 302138
|
2021-01-13 03:31:00 +01:00
|
|
|
dashedName: problem-463-a-weird-recurrence-relation
|
2018-09-30 23:01:58 +01:00
|
|
|
---
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --description--
|
|
|
|
|
2018-09-30 23:01:58 +01:00
|
|
|
The function $f$ is defined for all positive integers as follows:
|
2020-11-27 19:02:05 +01:00
|
|
|
|
2021-07-30 17:32:21 +02:00
|
|
|
$$\begin{align}
|
|
|
|
& f(1) = 1 \\\\
|
|
|
|
& f(3) = 3 \\\\
|
|
|
|
& f(2n) = f(n) \\\\
|
|
|
|
& f(4n + 1) = 2f(2n + 1) - f(n) \\\\
|
|
|
|
& f(4n + 3) = 3f(2n + 1) - 2f(n)
|
|
|
|
\end{align}$$
|
2020-11-27 19:02:05 +01:00
|
|
|
|
2021-07-30 17:32:21 +02:00
|
|
|
The function $S(n)$ is defined as $\sum_{i=1}^{n} f(i)$.
|
2020-11-27 19:02:05 +01:00
|
|
|
|
2021-07-30 17:32:21 +02:00
|
|
|
$S(8) = 22$ and $S(100) = 3604$.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2021-07-30 17:32:21 +02:00
|
|
|
Find $S(3^{37})$. Give the last 9 digits of your answer.
|
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-30 17:32:21 +02:00
|
|
|
`weirdRecurrenceRelation()` should return `808981553`.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
2021-07-30 17:32:21 +02:00
|
|
|
assert.strictEqual(weirdRecurrenceRelation(), 808981553);
|
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-30 17:32:21 +02:00
|
|
|
function weirdRecurrenceRelation() {
|
2020-09-15 09:57:40 -07:00
|
|
|
|
2018-09-30 23:01:58 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-07-30 17:32:21 +02:00
|
|
|
weirdRecurrenceRelation();
|
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
|
|
|
|
```
|