7
$\begingroup$

Possible Duplicate:
Proof for formula for sum of sequence $1+2+3+\ldots+n$?

I was just messing around in Haskell:

let fnc x = (sum [1..x], x * (x - 1) / 2) fnc 12 >> (78.0, 66.0) 

(I was just messing around after reading The Mythical Man Month: "Intercommunication is worse. If each part of the task must be separately coordinated with each other part/ the effort increases as n(n-I)/2.")

Then I noticed this:

[fnc x | x <- [1..20]] >> [(1.0,0.0),(3.0,1.0),(6.0,3.0),(10.0,6.0),(15.0,10.0),(21.0,15.0),(28.0,21.0),(36.0,28.0),(45.0,36.0),(55.0,45.0),(66.0,55.0),(78.0,66.0),(91.0,78.0),(105.0,91.0),(120.0,105.0),(136.0,120.0),(153.0,136.0),(171.0,153.0),(190.0,171.0),(210.0,190.0)] 

(Scratching head and thinking 'Hey, y is always the x of the last step')

And so I wrote:

let fnt x = (sum [1..x], (x + 1) * x / 2) fnt 3 >> (6.0,6.0) 

My math skills are horrible but I wanted to transform one side to the other. I failed. miserably.

Why are those equations equal? Are there any interesting benefits mathematically or computationally in defining sum as (x + 1) * x / 2 ?

  • 1
    Yes, this does appear to be an exact duplicate. Is it possible to merge the answers?2011-11-25

0 Answers 0