18cc926adbc038b0074f41f0fffc2276f0fdeaf9
[ghc-hetmet.git] / ghc / misc / examples / nfib / nfib.pl
1 # WARNING!
2 # Note: be careful about running this with an argument > (say) 18 !
3 # running this script on '27' will chew up ~80 MB of virtual
4 # ram. and its apetite grows per 1.61803 ** $n.
5 #
6 # Your system admin folk would probably be displeased if you trash
7 # other people's work, or disable systems running this script!
8
9 # Usage: perl nfib.prl <number>
10 #
11 $n = @ARGV[0];
12 $f=&fib($n);
13 print " $n! = $f\n";
14 sub fib {
15     local ($n)=$_[0];
16     if ($n==0) {return (0);}
17     elsif($n==1) {return(1);}
18     return (&fib ($n-1) + &fib($n-2));
19 }