emprit

prima

Oct 2nd, 2012
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. <?php
  2. echo "<form method='POST'  action='cetak.php'>";
  3. echo "masukkan bilangan awal : <input type='text' name= 'awal'>";
  4. echo "<input type=submit value='cetak bilangan prima'></form>";
  5.  
  6. if($_SERVER['REQUEST_METHOD']=='POST'){
  7.     $jum=0;
  8.     $awal=$_POST['awal'];
  9.     $a=0;
  10.     if($jum<=10){
  11.     while($i>=$awal){
  12.         $j=0;
  13.         while($j>$i)
  14.         if($i%$j==0){
  15.         $a++;
  16.         }
  17.         if($a==2){
  18.         echo $i.'<br>';
  19.         $jum=count($i); //bingung ambil nilai 1cetakan $i dihitung = 1
  20.                 //soalnya count kan buat ngitung hasil dr nilai $i dtambahkan trs
  21.         }
  22.     $i++;
  23.     }
  24. }
  25. }
  26.  
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment