Perl: fibonacci series

#fibonacci.pl

use strict;

print “\n\nEnter a number, 10 fibonacci series elements starting from that number will be displayed.”;
my $fbc = <STDIN>;
chomp ($fbc);
print “\n you entered $fbc\n”;
my $fb1=0;

for (0..10)
{
my $fb3= $fb1+ $fbc;
$fb1= $fbc;
$fbc=$fb3;
print “$fb3\t”;
}

Advertisements

Tags: , ,

One Response to “Perl: fibonacci series”

  1. koolkedar Says:

    Output of the above script is:

    Enter a number, 10 fibonacci series elements starting from that number will be displayed. 4

    you entered 4

    4 8 12 20 32 52 84 136 220 356
    576

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s


%d bloggers like this: