Posted By

Omnikron13 on 04/08/13


Tagged

php numbers Maths triangular


Versions (?)

Fast Triangular Numbers


 / Published in: PHP
 

URL: http://www.curiousmath.com/index.php?name=News&file=article&sid=95

Explanation of the method used here in the URL.

  1. <?php
  2. /*
  3.  * Due to being a simple piece of mathematics, my triangular number function is likely
  4.  * exempt from copyright, but just in case I eschew all copyright and give it entirely
  5.  * to the public domain.
  6.  * --Joey Sabey
  7.  */
  8.  
  9. function triangularNumber($_x) {
  10. return (($_x / 2) + 0.5) * $_x;
  11. }
  12.  
  13. ?>

Report this snippet  

You need to login to post a comment.