# Counting number of correlations between n variables in a set

Suppose I have a set of 40 variables

{A, B, C...}

I want to count the number of possible correlations for n variables. For example, if n=2

I have

40(40-1)/2=780 correlations

How do I do it for n > 2?

-
Well, how did you do it for $n=2$? – Pedro Tamaroff Sep 6 '12 at 23:51

What you did for $n=2$ works for $n\gt2$ (as Peter implies in a comment). For $n=3$, you get $$(40)(40-1)(40-2)/(1)(2)(3)$$ for $n=4$, $$(40)(40-1)(40-2)(40-3)/(1)(2)(3)(4)$$ and so on.