This week's function is summation using the Gauss method.
ASP
function sum(x, y)
sum = (x + y) * ((y - x + 1) / 2)
end function
PHP
function sum($x, $y)
{
return ($x + $y) * (($y - $x + 1) / 2);
}
ASP and PHP code that you can use and re-use. Practical examples for real-world programming, under a Creative Commons license.
All the code examples on this blog are licensed under a Creative Commons Attribution 3.0 License.
No comments:
Post a Comment