summaryrefslogtreecommitdiffstats
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
commit1a4e6e9708b4cdc426ebd1226a7f10f8e4259b75 (patch)
treeb3eb8e2975df384946ad70572e1e3387a6c3127c /sample/fib.pl
parentc56fc4a0e859bef2202e60c8e48834dfd4bf5034 (diff)
downloadruby-1a4e6e9708b4cdc426ebd1226a7f10f8e4259b75.tar.gz
ruby-1a4e6e9708b4cdc426ebd1226a7f10f8e4259b75.tar.xz
ruby-1a4e6e9708b4cdc426ebd1226a7f10f8e4259b75.zip
2000-02-23
git-svn-id: http://svn.ruby-lang.org/repos/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 c5593764a..945a4929a 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";