#P7586. Strength Sequence Sum
Strength Sequence Sum
Strength Sequence Sum
Given a positive integer \(N\), define a function \(f(N)\) as the smallest positive integer \(k > 1\) such that \(N\) is not divisible by \(k\) (i.e. \(N \bmod k \neq 0\)). Starting from \(N\), we generate a sequence:
[ N,\ f(N),\ f(f(N)),\ \ldots ]
It can be proven that if \(N \ge 2\), this sequence will eventually reach \(2\). We then define the strength of \(N\), denoted as \(\operatorname{strength}(N)\), to be the length of the sequence from \(N\) until the first occurrence of \(2\) (inclusive). For example, for \(N = 6\):
[ 6 \to 4 \to 3 \to 2 ]
Thus, \(\operatorname{strength}(6)=4\).
Given two positive integers \(A\) and \(B\) (with \(A \le B\)), compute the sum:
[ S = \sum_{i=A}^{B} \operatorname{strength}(i),. ]
</p>inputFormat
The input consists of a single line with two integers \(A\) and \(B\) (2 \(\le\) A \(\le\) B \(\le\) 106 or similar constraint), separated by a space.
outputFormat
Output a single integer, the value of \(S\) defined above.
sample
2 2
1