You are creating a recursive function so throw away your code, get a piece of paper, and write
then replace ... with an if/else structure that either returns a number, or adds the return value of a call to Fibonacci( $n ... ) ...it should follow closely the mathematical definition for Fibonacci number.sub Fibonacci { my $n = shift; ... }
In reply to Re: fibonacci numbers using subroutine?
by Anonymous Monk
in thread fibonacci numbers using subroutine?
by derpp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |