note 25725 deleted from ref.math by victor
| From: | victor@php.net | Date: | Sat, 22 Feb 2003 15:45:01 +0000 |
| Subject: | note 25725 deleted from ref.math by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-44346@lists.php.net to get a copy of this message | ||
I _NEVER_ thought I would need to use this after leaving school, but I did... To find a triangular
number (recursively)
eg. tri(5) = 5 + 4 + 3 + 2 + 1 = 15
function tri($x) {
if ($x == 1)
return 1;
else
return ($x + tri($x - 1));
}