You are given two positive integers P and Q where P < Q.
The strength of a positive number N i.e Strength(N) is defined as follows:
If X is the smallest positive integer such that X < N and doesn't not divide N then strength(N) = strength(X) + 1
If there is no positive integer lesser than N that doesn't divide N then strength(N) = 1
Calculate the sum of strengths of all integers between P and Q (inclusive)
3 <= P < Q <= 10^17
eg: strength(6) = strngth(4) + 1 = 2+ strngth(3) = 3+strngth(2) = 4.
I couldn't come up with any optimal solution, can anyone please help? Thanks!