Originally posted by Peter Shipway:
I would have to use a counter until it reaches 5 or n
0
0
0
0
0
0
etc.
(Don't worry about lining numbers up.) The rule for constructing the elements of this triangle t is as follows:
t[n][0] = 1, n >= 0
t[n][k] = t[n-1][k-1] + t[n-1][k], n >= 1, 1 <= k < n
t[n][n] = 1, n >= 1
Note that t[n][k] is the binomial coefficient C(n,k). What is the the value of C(20,10)?
t[n][0] = 1, n >= 0
t[n][k] = t[n-1][k-1] + t[n-1][k], n >= 1, 1 <= k < n
t[n][n] = 1, n >= 1
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
(remember, we start at 0). And, it's in row 5.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Tony Morris
Java Q&A (FAQ, Trivia)
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |