=$i){ if($num%$i==0){ echo $i.PHP_EOL; exit; } $i +=2; } //---------------------------------- if($num%2==0){ echo ($num/2).PHP_EOL; exit; }else{ echo $num.PHP_EOL; }