100)){
$error = "your iterations must be between 1 - 100";
}else{
$passes = $_GET['passes']; // Set number of iterations
}
}
for ($i = 1; $i <= $passes; $i++) { // How many passes to do
for ($j = $i; $j <= 100; $j += $i){ // Flip switch every x Lights
if($LightsBool[$j] == 0){
$LightsBool[$j] = 1;
} else if ($LightsBool[$j] == 1){
$LightsBool[$j] = 0;
}
}
}
if($error <> ""){ echo $error."
"; }
echo "number of passes = ".$passes."
";
echo "Lights on and off in order - ";
for ($i = 1; $i <= 100; $i++) {
echo $LightsBool[$i];
if($LightsBool[$i] == 1){ $LightsOn++; }
}
echo "
Lights on: ".$LightsOn." Lights off: ".(100 - $LightsOn)."
";
$page = "http://".$_SERVER["SERVER_NAME"]."/".substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
echo "Try another iteration By going to :".$page."/?passes=<no>
";
?>