summaryrefslogtreecommitdiff
path: root/sample/fib.pl
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-23 05:23:12 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-23 05:23:12 +0000
commitbf70582cf30ae6f715769c519f451411f5d2a577 (patch)
treeb3eb8e2975df384946ad70572e1e3387a6c3127c /sample/fib.pl
parent6f82a67fd0035fcd2802f1564165d5211bc98ea2 (diff)
2000-02-23
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/fib.pl')
-rw-r--r--sample/fib.pl19
1 files changed, 10 insertions, 9 deletions
diff --git a/sample/fib.pl b/sample/fib.pl
index c559376..945a492 100644
--- a/sample/fib.pl
+++ b/sample/fib.pl
@@ -1,10 +1,11 @@
- sub fib {
- local($n)=@_;
- if( $n<2 ){
- return $n;
- } {
- return &fib($n-2)+&fib($n-1)
- }
- }
+sub fib {
+ my($n)=@_;
+ if ($n<2) {
+ return $n;
+ }
+ else {
+ return fib($n-2)+fib($n-1);
+ }
+}
- print &fib(20), "\n";
+print fib(20), "\n";