PHP script for Fibonacci number


PHP script for first 20 Fibonacci numbers
<?php
$count = 0 ;
$c1 = 0;
$c2 = 1;
echo $c1.” , “;
echo $c2.” , “;
while ($count < 20 )
{
$c3 = $c2 + $c1 ;
echo $c3.” , “;
$c1 = $c2 ;
$c2 = $c3 ;
$count = $count + 1;
}
?>

<?php
/* Find number odd or even */
$num = 32;
$even = ($num % 2 == 0);
$odd = ($num % 2 != 0);
?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s