PHP Programing language

adplus-dvertising
How Can use a recursive function to sum an integer set
Previous Home Next
<html>
<head>
<title>Using a recursive function to sum an
integer set  </title>
</head>
<body>
<h1>Using a recursive function to sum an
integer set</h1>
<?
function summation ($c) 
{
     if ($c != 0) :
          return $c + summation($c-1);
     endif;
}
$sum = summation(100);
print "Summation = $sum";
?>
</body>
</html>

Output:

Previous Home Next