Discussion About Prateek Loves Candy

This is Discussion thread about Prateek Loves Candy

my email id is [email protected] I am getting a TLE in this problem the code for the problem is
https://ide.codingblocks.com/s/242455

I AM ALSO GETTING time limit ERROR. Please help

int times = 0;
Scanner scan = new Scanner(System.in);
if (scan.hasNextInt()) {
times = scan.nextInt();
}
while (times > 0) {
int number = scan.nextInt();
int var = 1;
int q = 2;
for (; var <= number;) {
int flag = 0;
for (int w = 2; w <= q / 2; w++) {
if (q % w == 0) {
flag = 1;
break;
}
}
if (flag == 0) {
//series: System.out.println(q);
var++;
}
q++;
}
System.out.println(–q);
times–;

	}
	scan.close();