Welcome Guest, Not a member yet? Register   Sign In
Hierarchical <ul><li> from MySql
#7

[eluser]zerone[/eluser]
[quote author="Grahack" date="1198000802"]This is all about recursion.
Here is an example to compute n!=nx(n-1)x(n-2)x...x4x3x2x1.
Code:
&lt;?php
function facto($n)
{
   if ( $n == 1 ) return 1;
   else return $n * facto( $n - 1 );
}
[/quote]

Indeed Tongue
It would be achieved by iteration, but this problem requires tree recursion.
But iteration is far more efficient.


Messages In This Thread
Hierarchical <ul><li> from MySql - by El Forum - 12-15-2007, 04:51 PM
Hierarchical <ul><li> from MySql - by El Forum - 12-16-2007, 02:25 AM
Hierarchical <ul><li> from MySql - by El Forum - 12-16-2007, 09:22 PM
Hierarchical <ul><li> from MySql - by El Forum - 12-16-2007, 09:40 PM
Hierarchical <ul><li> from MySql - by El Forum - 12-17-2007, 04:20 PM
Hierarchical <ul><li> from MySql - by El Forum - 12-18-2007, 06:00 AM
Hierarchical <ul><li> from MySql - by El Forum - 12-18-2007, 08:53 AM
Hierarchical <ul><li> from MySql - by El Forum - 12-18-2007, 09:04 AM
Hierarchical <ul><li> from MySql - by El Forum - 12-20-2007, 02:01 AM
Hierarchical <ul><li> from MySql - by El Forum - 10-25-2009, 01:49 PM
Hierarchical <ul><li> from MySql - by El Forum - 10-26-2009, 04:14 AM
Hierarchical <ul><li> from MySql - by El Forum - 08-04-2010, 09:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB