1 test case : timelimit eror

in the prime generator code , first i tried normal approach but it gave me an error of timelimit. soi decided to use seive of eratosthenis but still i am getting a timelimit error.

code: https://ide.codingblocks.com/s/119776

sir i want to know is there a better approach an what’s wrong with my approach

sir its been a week with no response. please solve the problem asap.

hi @pulkit10251
plz try to solve this problem and merge sort problem in c or c++
use sieve of eratosthenes approch for the above
that one test case is treating values in term 10^7