2018-10-10 22:03:03 +00:00
---
id: 5900f3c81000cf542c50fedb
2021-02-06 04:42:36 +00:00
title: 'Problem 92: Square digit chains'
2018-10-10 22:03:03 +00:00
challengeType: 5
2021-02-06 04:42:36 +00:00
forumTopicId: 302209
2021-01-13 02:31:00 +00:00
dashedName: problem-92-square-digit-chains
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
A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before.
For example,
< div style = 'margin-left: 4em;' >
44 → 32 → 13 → 10 → < strong > 1< / strong > → < strong > 1< / strong > < br >
85 → < strong > 89< / strong > → 145 → 42 → 20 → 4 → 16 → 37 → 58 → < strong > 89< / strong >
< / div >
Therefore any chain that arrives at 1 or 89 will become stuck in an endless loop. What is most amazing is that EVERY starting number will eventually arrive at 1 or 89.
How many starting numbers below ten million will arrive at 89?
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
`squareDigitChains()` should return a number.
```js
assert(typeof squareDigitChains() === 'number');
```
`squareDigitChains()` should return 8581146.
2018-10-10 22:03:03 +00:00
```js
2021-02-06 04:42:36 +00:00
assert.strictEqual(squareDigitChains(), 8581146);
2018-10-10 22:03:03 +00:00
```
2021-01-13 02:31:00 +00:00
# --seed--
## --seed-contents--
```js
function squareDigitChains() {
return true;
}
squareDigitChains();
```
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
```