Pari N Prime

I tried solving pari n prime problem from infinity2k18 challenge but my solution going timed out.
So i saw one of the solution but coudn’t understand the use of solve function why such computations being performed there.
Can someone explain me how it can be done or some way to do it?

The approach is-
Get all primes within 10^6.
for every prime p which is less than or equal to r, we can find out how many numbers are divisible by p in the range l to r (stored in mult). So the prime p is going to get added up mult times. so total=(total+mult*p)%1000000007.
Hope it clarifies.

Thanks for the reply!
But i don’t understand how they drive the below two lines
start = l + prime - mod
mult = 1 + (r - start)//prime

Because anything without a reason is a bit hard to digest @rp