Php Primzahlbestimmung?
Hey,
das wird fürs erste wahrscheinlich meine letzte frage zu php sein. Und zwar fehlt mir noch die Primzahlbestimmung. Ich hab es schonmal gefragt, jedoch hat es bisher noch nicht funktioniert.
<html>
<?php
$zahl1 = $_POST["zahl1"];
$zahl2 = $_POST["zahl2"];
$text = $_POST["text"];
$produkt = $zahl1*$zahl2;
$feld=array();
if($zahl1 < $zahl2) {
echo "Zahlen: $zahl1 und $zahl2 <br>";
for ($i=$zahl1; $i<=$zahl2;$i++)
{$feld[]=$i;}
foreach($feld as $zahl) {
if($zahl % 2 == 0) {
echo"<font color='red'>{$zahl}</font>";
}
else {
echo"<font color='blue'>{$zahl}</font>";
}
}
echo "<br> Produkt: $produkt <br> Zeichenkette: $text ";
echo strlen($text);
}
if($zahl2 < $zahl1) {
echo "Zahlen: $zahl2 und $zahl1 <br>";
for ($i=$zahl2; $i<=$zahl1;$i++)
{$feld[]=$i;}
foreach($feld as $zahl) {
if($zahl % 2 == 0) {
echo"<font color='red'>{$zahl}</font>";
}
else {
echo"<font color='blue'>{$zahl}</font>";
}
}
echo "<br> Produkt: $produkt <br> Zeichenkette: $text ";
echo strlen($text);
}
?>
</html>
Das ist mein code bisher und es funktioniert auch alles, bis auf die primzahlen. Wäre sehr nett
