diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-02-23 05:23:12 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-02-23 05:23:12 +0000 |
commit | bf70582cf30ae6f715769c519f451411f5d2a577 (patch) | |
tree | b3eb8e2975df384946ad70572e1e3387a6c3127c /sample/fib.pl | |
parent | 6f82a67fd0035fcd2802f1564165d5211bc98ea2 (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.pl | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/sample/fib.pl b/sample/fib.pl index c5593764aa..945a4929a7 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"; |