SP15864 SUMMING - SUMMING
Description
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$','$'], ['\\(','\\)']],
skipTags: ["script","noscript","style","textarea","code"]
}
});
Find the sum of $x$ smallest distinct numbers of the series $2^i \\times 3^j$ ($i, j \\ge 0$).
- the first number of the series is $1 = 2^0 \\times 3^0$
- the second number of the series is $2 = 2^1 \\times 3^0$
- the third number of the series is $3 = 2^0 \\times 3^1$
- the fourth number of the series is $4 = 2^2 \\times 3^0$
- the fifth number of the series is $6 = 2^1 \\times 3^1$
As the sum can be huge print sum **modulo** $k$.
Input Format
The input contains 2 numbers $x$ and $k$: $1 \\le x \\le 10^{14}$, $1 \\le k \\le 10^8$
Output Format
The output contains sum of the first $x$ numbers of the series **modulo** $k$.