habel's Blog

bilangan prima

Posted on: 23 Desember 2010

<html>
<head>
<title>bilangan prima denga javascript</title></head>
<script language="JavaScript">
<!--
var awal=prompt("masukkan nilai awal :");
var akir=prompt("masukkan nilai akir :");
var prima=false;

for (i=awal; i <=akir; i++)
{
 if(i>=2)
 {
 prima =true;
 for(j =2;j<i;j++)
 {
 if(i%j==0)
 {
 prima=false;
 }
 }
 }
 if(prima)
 {
 document.writeln(" " + i + " ");
 }
}
-->
</script>
</head>
<body>
</body>
</html>

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: