Fast Triangular Numbers

Submitted by:Andery Smith

Date added:27 April, 2013

Category:PHP

PHP code for Fast Triangular Numbers

Tags: triangular numbers

Code Snippet:

    <?php
/*
* Due to being a simple piece of mathematics, my triangular number function is likely
* exempt from copyright, but just in case I eschew all copyright and give it entirely
* to the public domain.
* --Joey Sabey
*/

function triangularNumber($_x) {
return (($_x / 2) + 0.5) * $_x;
}

?>
 
 

Comments