Advertisement
Guest User

Soal Test Nomer 4

a guest
Nov 24th, 2017
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.32 KB | None | 0 0
  1. <?php
  2.     /**
  3.      * Bilangan Prima
  4.      * @author Miftach Hidayatullah <miftarockavanka@gmail.com>
  5.      */
  6.     $y = 30;
  7.     for($x=2;$x<=$y;$x++)
  8.         {
  9.             $bilPrima = true;
  10.             for($z=2; $z<$x;$z++)
  11.                 {
  12.                     if($x%$z == 0){
  13.                         $bilPrima = false;
  14.                     }
  15.                 }
  16.             if($bilPrima){
  17.                 echo $x." ";
  18.             }
  19.                    
  20.         }
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement