2018-09-30 22:01:58 +00:00
---
id: 5900f4151000cf542c50ff28
2020-11-27 18:02:05 +00:00
title: >-
Problem 169: Exploring the number of different ways a number can be expressed
as a sum of powers of 2
2018-09-30 22:01:58 +00:00
challengeType: 5
2019-08-05 16:17:33 +00:00
forumTopicId: 301803
2021-01-13 02:31:00 +00:00
dashedName: >-
problem-169-exploring-the-number-of-different-ways-a-number-can-be-expressed-as-a-sum-of-powers-of-2
2018-09-30 22:01:58 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
2021-07-12 14:19:03 +00:00
Define $f(0)=1$ and $f(n)$ to be the number of different ways $n$ can be expressed as a sum of integer powers of 2 using each power no more than twice.
2020-11-27 18:02:05 +00:00
2021-07-12 14:19:03 +00:00
For example, $f(10)=5$ since there are five different ways to express 10:
2020-11-27 18:02:05 +00:00
2021-07-12 14:19:03 +00:00
$$\begin{align}
& 1 + 1 + 8 \\\\
& 1 + 1 + 4 + 4 \\\\
& 1 + 1 + 2 + 2 + 4 \\\\
& 2 + 4 + 4 \\\\
& 2 + 8
\end{align}$$
2020-11-27 18:02:05 +00:00
2021-07-12 14:19:03 +00:00
What is $f({10}^{25})$?
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
2021-07-12 14:19:03 +00:00
`numberOfWaysToExpress()` should return `178653872807` .
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
2021-07-12 14:19:03 +00:00
assert.strictEqual(numberOfWaysToExpress(), 178653872807);
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
2021-07-12 14:19:03 +00:00
function numberOfWaysToExpress() {
2020-09-15 16:57:40 +00:00
2018-09-30 22:01:58 +00:00
return true;
}
2021-07-12 14:19:03 +00:00
numberOfWaysToExpress();
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
```js
// solution required
```