in reply to How do I write a program that calculates the sum of all numbers to a number, n?

This response is not intended to be taken literally. :p

The sum of ALL numbers being negative 1/12, would the sum of all numbers up to N not be some type of a function? In the manner of

sum( N,N-1,N-2..N=1 ) = N / ( -1/12 )

Oh yes, I see now n(n+1)/2, overthinking it again.

Although that might be N * -1/12 (but is probably neither). For another undefined definition, maybe just bitmasking the sum of all numbers to length N. This could work well if soan is truly irrational.

sub donotrun_this_is_an_example{ use constant Soan = (-1/12); my $bitmask = ~ -256**($n/8); return Soan & $bitmask; }

similar idea would be to return the of multiplying Soan by 10 to power of N: int( Soan*10**$n )

Edit: Soan is negative 1/12


Alert! vague conjecture recollection syndrome and Random thought process combination.