';
$i=1;
$tmpArr = array(0=>'x', -1=>'x');
if($nr[1]==1){
echo '
JAH
0';
exit;
}
$count = 1;
echo $i.'->';
while(true){
$i = $nr[$i];
echo $i.'->';
if($i==1){
echo 'lõpp!';
$val = fopen('jada.val','w');
fwrite($val,'JAH\n');
fwrite($val, $count);
fclose($val);
exit;
}else{
if(array_key_exists($i, $tmpArr)){
echo 'stop! tsükkel!';
$val = fopen('jada.val','w');
fwrite($val, "EI\n");
fclose($val);
exit;
} else {
$tmpArr[$i] = 'x';
$count++;
}
}
}
?>