Test case failed in "Not so easy math" problem

Sir, in this question the upper limit of n is 10^18 but there can be a seive array upto 10^8 only. Due to this problem one test case failed in my solution. Kindly look into it or suggest some other good method to tackle the numbers as big as 10^18.

check this

@Shamikh07 use segmented sieve

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.