Saturday, 18 March 2017

Recursive function to sum an integer set in PHP

<?
function summation ($count) {
     if ($count != 0) :
          return $count + summation($count-1);
     endif;
}
$sum = summation(10);
print "Summation = $sum";
?>

No comments:

Post a Comment