Formula n(n-1)/2

I know that n(n+1)/2 is getting the sum of 1 to n numbers.
How about the n(n-1)/2?

where and when do we use this formula? and what other formulas are related to these two?


I’d say, that if \frac{n(n+1)}{2} is som of n numbers, then \frac{(n-1)n}{2} is the sum of n-1 numbers, do you agree?

You know, it’s not easy to answer the question without the proper context…

Second formula can also be used to find out number of combinations how to choose two elements out of n, or how many elements Ai,j are in square matrix where i < j and probably one can find another dozen of descriptions…


As @betlista has said, n(n-1)/2 is the sum of the first (n-1) numbers, that is

1 + 2 + 3 + 4 + .......... + (n-1)

Now one might think that there is not much use for this formula, but when you do some research, you can find interesting uses for it. @betlista has explained a few uses. Here is a link which explains one usage


So basically it is a combination formula where you need to choose r element out of n and order does not matter.

n * (n-1) / 2

Same as NCR forumula which is N! / (N-R)! * R!


Bruh its been six years


Legend says he is still asking this question. Duhhhh


Your answer is right , if you look at T(n) for insertion sort here you can see how outer loop runs for n(n+1)/2 -1 times and inner while runs one less than test case which again yields (n-1)(n-1+1)/2=n(n-1)/2

(n + 1) * (n + 2)/ 2 are both are same n*(n + 1) / 2

can anyone explain?

n*(n-1)/2 .This formula is mostly used to find total number of subarrays for a given array of size n

1 Like

I think it should have been \frac{n\times (n+1)}{2}. You missed subarrays of size 1.

nC2 ->Combination, number of handshakes


This link is not working.

It was posted in 2015


use n as 5
it give sum of n number
n*(n+1)/2 = 5(5+1)/2=15

it give sum of n+1 number
(n+1)(n+2)/2 =(67)/2=31

it give sum of n-1 number
n*(n-1)/2 = 5(5-1)/2=10

it give sum of square n2
n(n+1)(2n+1)/6 = 5(6)(11)/6=55

it give sum of cube n3
[ n*(n-1)/2]2 =( 5(5-1)/2)2=100


There are a lot of good answers here, I think he found the answer to his question