Last test case showing TLE


here is d link to my code kindly modify and tell

hey @pratyush.5 use sieve of eratosthenes concept
becuzz Constraints is too big

a<=1000000 & b<=1000000.


you can see this

this is not taught in this course how comeI am suppose to know this?? Where this concept has been taught??

this is a part of competitive coding. you can search on google
The sieve of Eratosthenes is one of the most efficient ways to find all primes smaller than n when n is smaller than 10 million
the time complexity of Sieve of Eratosthenes is n*log(log(n))

find all the prime numbers less than or equal to a given integer n by the Eratosthene’s method:

  1. Create a list of consecutive integers from 2 to n : (2, 3, 4, …, n ).
  2. Initially, let p equal 2, the first prime number.
  3. Starting from p^2, count up in increments of p and mark each of these numbers greater than or equal to p^2 itself in the list. These numbers will be p(p+1) , p(p+2) , p(p+3) , etc…
  4. Find the first number greater than p in the list that is not marked. If there was no such number, stop. Otherwise, let p now equal this number (which is the next prime), and repeat from step 3.
    https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes