summaryrefslogtreecommitdiff
path: root/sample/fib.pl
diff options
context:
space:
mode:
Diffstat (limited to 'sample/fib.pl')
-rw-r--r--sample/fib.pl10
1 files changed, 10 insertions, 0 deletions
diff --git a/sample/fib.pl b/sample/fib.pl
new file mode 100644
index 0000000..c559376
--- /dev/null
+++ b/sample/fib.pl
@@ -0,0 +1,10 @@
+ sub fib {
+ local($n)=@_;
+ if( $n<2 ){
+ return $n;
+ } {
+ return &fib($n-2)+&fib($n-1)
+ }
+ }
+
+ print &fib(20), "\n";