Re: Recursive Static Method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Works for me:

$ cat recurses.php ; php -q recurses.php
<?php
class recurses {
        static function factorial ($n) {
                assert(is_int($n));
                if ($n == 0) return 1;
                return $n * self::factorial($n - 1);
        }
}

echo "4! = ", recurses::factorial(4), "\n";
?>
4! = 24

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux