Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Adj meg egy számot: (0-255)
- <form method="post" action>
- <input type="text" name="szam"/><br/>
- <input type="submit"/>
- </form>
- <?php
- $a = 0;
- if (isset($_POST['szam'])){ $a=$_POST['szam']; }
- if (!empty($a)){ // nem üres (not empty)
- if (($a > "0")AND($a < "255")){ // 0-255 közé esik-e
- function primszam($a)
- {
- $k=0;
- for ($i = 1; $i <= $a; $i++)
- {
- $c = $a % $i;
- if ($c == 0) {$k++;}
- }
- if ($k <= 2) { return "Primszám"; }
- else { return "Nem prímszám"; }
- }
- echo(primszam($a).(" a/az ").($a));
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement