Return to Snippet

Revision: 63105
at April 8, 2013 16:01 by Omnikron13


Updated Code
<?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;
}

?>

Revision: 63104
at April 8, 2013 15:50 by Omnikron13


Initial Code
<?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_2($_x) {
    return (($_x / 2) + 0.5) * $_x;
}

?>

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

Initial Description
Explanation of the method used here in the URL.

Initial Title
Fast Triangular Numbers

Initial Tags
php

Initial Language
PHP