Hey everybody,
I have to make a prime number calculator.
I am doing it in php, since it is the language which i know best.
So, I got started, and have yet to finish writing the algorithm into it, but it already doesnt work. I have tried everything I know here, but it doesnt seem to work. Just prints out "1 is a factor" I see that that is $y and it I guess is not finishing my for loop. I checked and all the syntax seems correct, but I am probably wrong.
CODE
<html>
<head><ul style= color:white;><center>Is your number prime???</center>
<title>Prime Numbers</title>
</head>
<body bgcolor="black">
<ul style=color:white;>
<p>Enter Number<form action="prime.php" method="post">
<?php
print(" <p> <input type = 'text' name= 'number' size= '8'>");
$number = $_POST['number'];
For($y = 1; $y <= $number / 2; $y++) {
$z = $number % $y;
If($z ==0) {
print("$y is a factor.");
break;
}
}
?>
</body>
</html>
Thanks in advanced for any suggestions you have!