I know that the mathematical function for 5 * 4 * 3 * 2 * 1 is called factorial (and there is a PHP function for it: gmp_fact(n)).
But what is it called when you are wanting to add instead of multiply? Like this: 5 + 4 + 3 + 2 + 1? And is there a PHP function for this? Or do I need to roll my own? I assume there is a function for something like this but since I don’t know what the mathematical name is for this kind of expression I can’t seem to find the name of the function for it…
n * (n + 1) / 2These are called Triangular Numbers