Posted By

iamdezzy on 02/28/11


Tagged

math mathematics sum symbol summation


Versions (?)

Function for Summation


 / Published in: PHP
 

Easy but powerful.

  1. <?php
  2. function sum($from, $to){
  3. if ($from == $to) {
  4. return $from;
  5. }
  6. return $to + sum($from,$to-1);
  7. }
  8.  
  9. echo sum(8,100);
  10. ?>

Report this snippet  

You need to login to post a comment.