2018-09-30 22:01:58 +00:00
---
id: 5900f4f81000cf542c51000b
title: 'Problem 396: Weak Goodstein sequence'
2020-11-27 18:02:05 +00:00
challengeType: 5
2019-08-05 16:17:33 +00:00
forumTopicId: 302061
2021-01-13 02:31:00 +00:00
dashedName: problem-396-weak-goodstein-sequence
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 any positive integer n, the nth weak Goodstein sequence {g1, g2, g3, ...} is defined as:
2020-11-27 18:02:05 +00:00
g1 = n
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
for k > 1, gk is obtained by writing gk-1 in base k, interpreting it as a base k + 1 number, and subtracting 1.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
The sequence terminates when gk becomes 0.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
For example, the 6th weak Goodstein sequence is {6, 11, 17, 25, ...}: g1 = 6. g2 = 11 since 6 = 1102, 1103 = 12, and 12 - 1 = 11. g3 = 17 since 11 = 1023, 1024 = 18, and 18 - 1 = 17. g4 = 25 since 17 = 1014, 1015 = 26, and 26 - 1 = 25.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
and so on.
2018-09-30 22:01:58 +00:00
It can be shown that every weak Goodstein sequence terminates.
2020-11-27 18:02:05 +00:00
Let G(n) be the number of nonzero elements in the nth weak Goodstein sequence. It can be verified that G(2) = 3, G(4) = 21 and G(6) = 381. It can also be verified that ΣG(n) = 2517 for 1 ≤ n < 8.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
Find the last 9 digits of ΣG(n) for 1 ≤ n < 16.
2018-09-30 22:01:58 +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
`euler396()` should return 173214653.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert.strictEqual(euler396(), 173214653);
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 euler396() {
2020-09-15 16:57:40 +00:00
2018-09-30 22:01:58 +00:00
return true;
}
euler396();
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
```js
// solution required
```