12-18-2007, 06:00 AM
[eluser]Grahack[/eluser]
This is all about recursion.
Here is an example to compute n!=nx(n-1)x(n-2)x...x4x3x2x1.
This is all about recursion.
Here is an example to compute n!=nx(n-1)x(n-2)x...x4x3x2x1.
Code:
<?php
function facto($n)
{
if ( $n == 1 ) return 1;
else return $n * facto( $n - 1 );
}