This series is similar to Fibonacci Series defined as :
a = a = 0 and
For n > 1, a[n] = a[n - 1] + f(n), where f(n) is smallest prime factor of n.
for N in (1 < N < 10^7). Spoj Link for this problem .
I have solved this problem in c & Python. But due to long range, I am getting Time Limit Exceeded in Python. For small range this is working fine. Is there any alternative way do this in Python or can this be more optimized.
lst =  lst.append(0) lst.append(0) i = 2 while i <10000000 : t = 2 while t <= i : if i % t == 0 : break t +=1 lst.append(lst[i-1]+t) i +=1 for _ in range(int(input())): print(lst[int(input())])