Saturday, December 6, 2008

Summation

This week's function is summation using the Gauss method.


ASP

  1. function sum(x, y)
  2.     sum = (x + y) * ((y - x + 1) / 2)
  3. end function

PHP

  1. function sum($x, $y)
  2. {
  3.     return ($x + $y) * (($y - $x + 1) / 2);
  4. }

No comments: