The 12th-century writer Bhaskara gives an algorithm in his Lilavati to find the nth row in the Pascal's triangle. We start by writing the numbers 1, 2, . . ., n, and above them write the numbers n, n − 1, . . ., 2, 1, like so (shown for n = 5):
5 4 3 2 1
1 2 3 4 5
The first number in the row is 1 (this is true for every n). Obtain the other numbers in the row by successively multiplying and dividing by the numbers you have written:
1 · 5/1 = 5;
5 · 4/2 = 10;
10 · 3/3 = 10;
10 · 2/4 = 5;
5 · 1/5 = 1.
This algorithm is iterative; you do not have to generate any previous rows in order to find row n.