Skip to content

Commit

Permalink
Merge pull request TheRenegadeCoder#1944 from SourabhBadhya/95492
Browse files Browse the repository at this point in the history
Added Fibonacci in Perl
  • Loading branch information
jrg94 authored Oct 1, 2020
2 parents 8560f97 + d173cf1 commit 5fcd26f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion archive/a/autohotkey/hello-world.ahk

This file was deleted.

20 changes: 20 additions & 0 deletions archive/p/perl/fibonacci.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/perl
$num_args = $#ARGV + 1;
if ($num_args == 0) {
print "Usage: please input the count of fibonacci numbers to output\n";
} elsif ($num_args == 1) {
if ($ARGV[0] =~ /[0-9]+/) {
$n = $ARGV[0];
$result = 0,$first = 0,$second = 1;
for ($i = 1;$i <= $n;$i = $i + 1) {
$result = $first + $second;
$first = $second;
$second = $result;
print "$i: $first\n";
}
} else {
print "Usage: please input the count of fibonacci numbers to output\n";
}
} else {
print "Usage: please input the count of fibonacci numbers to output\n";
}

0 comments on commit 5fcd26f

Please sign in to comment.