Code compilation error

here is the link

please reply fast

Hey @yusuf
just a change
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();

    int PrimeNo=0;
    //for two input

for (int i = 0; i <n;i++) { // mera change

        int term = scn.nextInt();
        int num = 2;
        int LargestPrime = 0;

        for (int j = 1; j <= term;) {

            int divisor = 2;
            Boolean flag = true;
            while (divisor < num) {
                if (num % divisor == 0) {
                    flag = false;
                }
                divisor = divisor + 1;


            }
            if (flag ==true) {
                j++;
                PrimeNo = num;
            }

            //evalution of largest prime
            if (LargestPrime < PrimeNo) {
                LargestPrime = PrimeNo;

            }
            num++;


        }
        System.out.println(LargestPrime);



    }
}

}
its gives TLE .
optimize your solution

it is giving tle …what is tle and how to overcome this

@yusuf
use sieve of eratosthenes concept

i haven’t studied it yet.there is no lecture on that;how can i implement it

@yusuf

  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 p2 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.