prog: aufgabe vom 24-11-25, inf: flanken code

PROGT:
- wie viel reiskörner auf jedem feld eines schachbrett ist und wie viel kg auf dem schachbrett ist
- primzahlrechner

INF:
code zum  mitschrieb von inf
This commit is contained in:
danielvici123
2024-11-21 10:48:26 +01:00
parent 889419c762
commit 3b725c575e
5 changed files with 165 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
<?php
$zahl = $_REQUEST["zahl"];
$isPrime = true;
if ($zahl <= 1) {
$isPrime = false;
} else {
for ($i = 2; $i <= sqrt($zahl); $i++) {
if ($zahl % $i == 0) {
$isPrime = false;
break;
}
}
}
if ($isPrime) {
echo "Die Zahl $zahl ist eine Primzahl";
} else {
echo "Die Zahl $zahl ist keine Primzahl";
}
?>