3 ms·
Can you give an example?
by steve19 15y ago
Can you give an example?
- reinhardt 15y agoSure, here's one: given a list of n items, compute the sum of pairwise distances between every pair of items. The first item has distance 1 from the second, 2 from the third, ..., n-1 from the last. Similarly, the second item has distance 1 from the third, 2 from the fourth, ..., n-1 from the last. And so on until the (n-1)-th item. Expressed as a finite sum, this amounts to: sum (sum j, j=1 to n-i), i=1 to n-1 Paste this to Wolphram Alpha and you get the answer in a closed form: http://www.wolframalpha.com/input/?i=sum+%28sum+j%2C+j%3D1+to+n-i%29%2C+i%3D1+to+n-1 http://www.wolframalpha.com/input/?i=sum+%28sum+j%2C+j%3D1+t...