#!/afs/athena/contrib/perl5/perl

$size = 8190;
$starttime = time();
while(1){
    $count = 0;
    for($i=0;$i<=$size;$i++){
	$flags[$i] = 1;
    }
    for($i=0;$i<=$size;$i++){
	if($flags[$i]){
	    $prime=$i+$i+3;
	    for($k=($i+$prime);$k<=$size;$k+=$prime){
		$flags[$k]=0;
	    }
	    $count++;
	}
    }
    $iterations++;
    $elapsed = time()-$starttime;
    last if($elapsed >=10);
}
$seconds = $elapsed;
$score = $iterations/$seconds;
print("$iterations iterations in $seconds seconds\n");
if($count != 1899){
    print("Error: count <> 1899\n");
}
else{
    print("Sieve score = $score\n");
}
