2 / 2
Feb 2016

<?php
$stdin = fopen('php://stdin', 'r');
$testcase = fgets($stdin);
$n=1;
while($n<=$testcase){
$start = fgets($stdin);
$end=fgets($stdin);
if($start==1)
{
$start=2;
}
for($i=$start;$i<$end;$i++){
$flag=0;

for($j=2;$j<$i;$j++){

if($i%$j==0){
	$flag=1;
	break;
	}
}
if($flag==0){
		echo $i."\n";
	}

}

$n++;

}

fclose($stdin);

?>

can please anyone help me why its show time limit exceed

  • created

    Feb '16
  • last reply

    Feb '16
  • 1

    reply

  • 816

    views

  • 2

    users

Let me quote leppy:

Your definition of a prime number seems to be "a number that is not
divisible by a number less than iself ". You need to reduce this
definition to a smaller dataset.

and please correct the formatting of your code