1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
|
# If there is 1 person, no case of hand shaking is possible.
# If there are 2 persons, 1 case of hand shaking is possible.
# If there are 3 persons, 3 cases of hand shaking are possible.
# If there are 4 persons, 6 case of hand shaking are possible.
# nCn-1 = n*(n-1)/2
par(mfrow = c(1, 2))
x=1:10
y=c(0, 1, 3, 6, 10, 15, 21, 28, 36, 45)
plot(x, y)
lines(x, y, lty=21, col="red")
x=1:100
y=x*(x-1)/2
plot(x, y)
lines(x, y, lty=21, col="red")
text(20, 4000, "y=x*(x-1)/2")
|