So I have the little prime number calculator.
<?php
$number=$_GET['number'];
echo 'Input: '.$number.'<br><br>';
if((string)(int)$number == $number) {
if($number>1 && $number<10000000){
$status=0;
$x=2;
while($status==0){
$y=$number/$x;
if((string)(int)$y == $y){
$status=1;
echo 'Sorry. '.$number.' is not a prime number.';
}
if($x+1==$number){
$status=1;
echo 'Yes. '.$number.' is a prime number.';
}
$x++;
}
}
else{
echo 'Please specify a number between 1 and 10.000.000';
}
}
else{
echo 'Please specify a number. May not contain decimals, dots or commas.';
}
?>
How can I know how much server power it uses to calculate a high number. It could be nice if I could allow a higher number than 10 millions without people sucking all the resources.
Question: How do I know how long it took to perform the task and how do I know how many percent of the cpu and ram it used?