Bilangan Fibonachi Dengan PHP

Minggu, 05 Mei 2013

UTS-1.php
[php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>UTS 1</title>
</head>

<body>
Masukan batas perulangan<br />
<form action="UTS-2.php" method="post">
<input type=text name='bil'/>
<input type = submit value="Jalankan"/>
</form>

</body>
</html>

[/php]

[php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?
echo "Hasil Perulangan<br>";
$bil=$_POST['bil'];
$a=1;
$b=1;

echo $a."";
echo "1 "; 

for ($urut= 1;$urut<=$bil;$urut++)
 {
  $a=$a+$b;
  $b=Sa-$b+$a;
 
  if ($a %2==1)
   {
     echo("<font color=red>$a</font>"."  ");
   }
   else
   if ($a %2==0)
   {
    echo("<font color=blue>$a</font>"."  ");
   } 
 }
?>
<br>
<a href="UTS-1.php">Kembali</a>
</body>
</html>
[/php]
Share this article :

0 komentar:

Speak up your mind

Tell us what you're thinking... !

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. jakainfo.blogspot.com - All Rights Reserved
Template Created by Creating Website Inspired by Sportapolis Shape5.com
Proudly powered by Blogger