hnd has asked for the wisdom of the Perl Monks concerning the following question:
#factorial through recursion use strict; use warnings; print "enter number\n"; my $num=<>; &fact($num,1); print "factorial: \n"; ################## sub fact { my($num1,$flag)=shift; if($num1==0) print "$flag" and die "brrrrrrrreeeeeee :D\n"; else {fact($num1-1,$num1*$flag);} }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: factorial through recursion
by blokhead (Monsignor) on Jul 23, 2009 at 19:48 UTC | |
Re: factorial through recursion
by ikegami (Patriarch) on Jul 23, 2009 at 19:55 UTC | |
by lidden (Curate) on Jul 24, 2009 at 09:36 UTC | |
by ikegami (Patriarch) on Jul 24, 2009 at 16:10 UTC | |
Re: factorial through recursion
by SuicideJunkie (Vicar) on Jul 23, 2009 at 19:45 UTC | |
Re: factorial through recursion (diagnostics)
by toolic (Bishop) on Jul 23, 2009 at 20:13 UTC | |
Re: factorial through recursion
by imrags (Monk) on Jul 24, 2009 at 06:56 UTC | |
Re: factorial through recursion
by Anonymous Monk on Jul 23, 2009 at 19:53 UTC |