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.
- ' Returns the triangular number for a given number.
- function triangularNumber(someNumber)
- dim i
- dim result
- result = 0
- for i = 1 to someNumber
- result = result + i
- triangularNumber = result
- end function
CommentsSubscribe to comments
You need to login to post a comment.