Before some troll comes along and criticizes this function, bear in mind that it has legitimate uses. For example, it can be used to solve the handshake problem: how many handshakes if each person in a room full of n+1 total people shakes hands once with each other person?
- Copyright (c) 2009, reusablecode.blogspot.com; some rights reserved.
- This work is licensed under the Creative Commons Attribution License. To view
- a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
- send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
- 94305, USA.
- function triangularNumber($number)
- for($i = 1; $i <= $number; $i++)
- $result += $i;
- return $result;
CommentsSubscribe to comments
You need to login to post a comment.