Given the set $\{1,2,\dots,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\}$.
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)]$.
There are exactly five odd-triplets with $n \le 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]$.
How many odd-triplets are there with $n \le 10^{12}$?
This problem requires a bit of combinatorial mathematics. First, let’s understand what is happening in $f(n, k)$. It counts the amount of odd sums in $\binom{n}{k}$, when $n$ and $k$ are odd. We denote $\binom{n}{k}$ as ‘n choose k’, mathematically this is the number of ways to choose k items from a set n. It is calculated by the formula $n! / ((n-k)! \cdot k!)$.
The number of odd sums in $\binom{n}{k}$ is hard to count directly. An easier way to think about it is noting that for every subset with an odd sum, there will be a ‘complement’ subset that will add up to an even number. So for any set, half of the sums will be odd, and half will be even.
Now that we have that, we can notice that when $n$ and $k$ are both odd, $\binom{n}{k}$, which is the total count of the subsets, will also be odd. And since half of these will result in an odd sum, $f(n,k)$ is also odd when n and k are odd.
Therefore, to count the number of triplets $(n, k, f(n, k))$, we only need to count the number of odd numbers from 1 to $10^{12}$ ($n$), and for each number, count the number of odd numbers from 1 to $n$ ($k$). So for every odd number $n$, there are $(n+1)/2$ odd numbers from 1 to $n$.
In a given range 1 to $10^{12}$, the number of odd numbers is $(10^{12} + 1)/2 = 5*10^{11}$.
And for each number $n$, the number of odd numbers less than or equal to $n$ is $(n + 1)/2$.
So the total number of odd triplets $(n, k, f(n, k))$ is the sum of all odd numbers less than or equal to each odd number up to $10^{12}$. To get this, we sum up $(n + 1)/2$ for each odd number $n$ from 1 to $10^{12}$.
We can simplify this as a sum of an arithmetic series where the first term $a$ is 1, the last term $l$ is $(10^{12} + 1)/2 = 5*10^{11}$ and there are $n = 5*10^{11}$ terms.
The formula for the sum of an arithmetic series is $\frac{{n \cdot (a + l)}}{2}$, therefore, substituting gives
$\frac{(5*10^{11}) \cdot (1 + 5*10^{11})}{2}$ multiplying gives, $1.25 * 10^{23} + 1.25*10^{34}$, i.e,
$\boxed{1.25 * 10^{34}}$ odd triplets with $n \le 10^{12}$.
Note: For a large data set like $10^{12}$, computational software would be needed to carry out such calculations in real life.
More Answers:
Twenty-two Foolish PrimesTop Dice
Perfection Quotients