File: primzahl.htm

package info (click to toggle)
selfhtml 8.1.2-1
  • links: PTS
  • area: non-free
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, squeeze, stretch, wheezy
  • size: 28,076 kB
  • ctags: 4,161
  • sloc: xml: 614; java: 375; makefile: 8
file content (35 lines) | stat: -rw-r--r-- 1,038 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Test</title>
<script type="text/javascript">
function PrimzahlCheck (Zahl) {
  Zahl = parseInt(Zahl, 10);
  if (isNaN(Zahl)) {
    alert("Sie mssen eine Zahl eingeben!");
    return;
  }
  var Grenzzahl = Zahl / 2;
  var Check = 1;
  for (var i = 2; i <= Grenzzahl; i++)
    if (Zahl % i == 0) {
      alert(Zahl + " ist keine Primzahl, weil teilbar durch " + i);
      Check = 0;
    }
  if (Check == 1)
    alert(Zahl + " ist eine Primzahl!");
}
</script>
</head>
<body>
<form name="PrimzahlFormular" action="">
<p>Geben Sie eine Zahl ein. Es wird geprft, ob es sich um eine Primzahl handelt.</p>
<input type="text" name="Eingabezahl">
<input type="button" value="auf Primzahl checken"
onclick="PrimzahlCheck(document.PrimzahlFormular.Eingabezahl.value)">
</form>

<p><a href="../funktionen.htm#aufrufen">zur&uuml;ck</a></p>
</body>
</html>