2018-09-30 22:01:58 +00:00
---
id: 5900f45f1000cf542c50ff71
title: 'Problem 242: Odd Triplets'
2020-11-27 18:02:05 +00:00
challengeType: 5
2019-08-05 16:17:33 +00:00
forumTopicId: 301889
2021-01-13 02:31:00 +00:00
dashedName: problem-242-odd-triplets
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
2021-07-16 10:21:45 +00:00
Given the set {1,2,..., $n$}, we define $f(n, k)$ as the number of its $k$-element subsets with an odd sum of elements. For example, $f(5,3) = 4$, since the set {1,2,3,4,5} has four 3-element subsets having an odd sum of elements, i.e.: {1,2,4}, {1,3,5}, {2,3,4} and {2,4,5}.
2018-09-30 22:01:58 +00:00
2021-07-16 10:21:45 +00:00
When all three values $n$, $k$ and $f(n, k)$ are odd, we say that they make an odd-triplet $[n, k, f(n, k)]$.
2018-09-30 22:01:58 +00:00
2021-07-16 10:21:45 +00:00
There are exactly five odd-triplets with $n ≤ 10$, namely: $[1, 1, f(1, 1) = 1]$, $[5, 1, f(5, 1) = 3]$, $[5, 5, f(5, 5) = 1]$, $[9, 1, f(9, 1) = 5]$ and $[9, 9, f(9, 9) = 1]$.
2018-09-30 22:01:58 +00:00
2021-07-16 10:21:45 +00:00
How many odd-triplets are there with $n ≤ {10}^{12}$?
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-16 10:21:45 +00:00
`oddTriplets()` should return `997104142249036700` .
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
2021-07-16 10:21:45 +00:00
assert.strictEqual(oddTriplets(), 997104142249036700);
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-16 10:21:45 +00:00
function oddTriplets() {
2020-09-15 16:57:40 +00:00
2018-09-30 22:01:58 +00:00
return true;
}
2021-07-16 10:21:45 +00:00
oddTriplets();
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
```