3
PASCAL’S TRIANGLE

In this chapter, we discuss Pascal’s triangle and explain the relevance of its entries to number theory.

FACTORIALS

As you are probably aware, n!, or n factorial, is the product of the first n positive integers, that is,

images

We define 0! to be 1. There are n! permutations of n distinct objects.

THE COMBINATORIAL NUMBERS n CHOOSE k

Let us consider the following problem. Given n distinct objects, in how many ways can we select k of them where order does not matter? If I have three extra tickets to a baseball game and I have 10 friends, in how many ways can I select the lucky trio of friends who will receive free tickets? Here, order does not matter. The choice Newton, Archimedes and Euclid is the same as the choice Euclid, Newton and Archimedes.

We begin with the first k factors of n!, namely, images . This is because there are n ways to pick the first object, n − 1 ways to pick the second object, and so on till the last choice (the kth object), which can be made in (n − k + 1) ways.

The expression images is too big to be the answer to our problem. To see this, consider the number of combinations of three objects from among six distinct objects. Let the six objects be the letters A through F. The three-letter choice ACD, for example, will be counted six times instead of once. It will appear in the list of permutations as ACD, ADC, CDA, CAD, DCA, and DAC. But we only want it (and all the other combinations such as ACE, etc.) listed once in the list of combinations. So we divide by 6—the number of permutations of three objects. This suggests the following procedure for the number of combinations of k objects chosen from among n distinct objects. Divide the product images by k!. In symbols,

The symbol on the left of Equation 3.1 is pronounced “n choose k.” If we multiply the numerator and denominator by (n − k)!, we obtain the alternative formula

The numerator of the middle expression in (3.2a) is seen to be n! after we expand the (n − k)!, thereby realizing it supplies all the factors of n! that were missing in the numerator of 3.1.

Let’s rewrite (3.2a) without the middle expression:

The numbers k and n − k in the denominator of (3.2b) are called complements because they add up to n. If we replace each k by its complement, n − k, we obtain

images

or, more simply,

(3.3)images

After all, choosing a meal of k dishes from a menu of n is equivalent to indicating the n − k dishes not chosen. Thus, to evaluate images , it is easier to evaluate images .

Observe that “n choose n” yields two answers, which may be compared. On the one hand, it is, using formula (3.2b), images , while on the other hand, common sense tells us that the answer must be 1. (There is only one way to choose all n objects.) It follows that 0! must be 1. Moreover, it follows that images .

Another useful observation is that images .. This could, of course, be verified without the help of Equation 3.1 by using common sense. There are n ways to choose one item among n distinct items.

PASCAL’S TRIANGLE

There is an ancient array of numbers called Pascal’s triangle, shown below up to the seventh row. (The name of the row is given by the second entry, printed in bold.)

pg-48

Each entry is the sum of the two entries immediately above it. Thus, the first 35 in the seventh row is the sum of the 15 and 20 in the sixth row. You should have no trouble obtaining the entries of the eighth row using this method of generation.

BINOMIAL COEFFICIENTS

Now, it is amazing that the entries of the nth row of Pascal’s triangle consist of the n + 1 combinatorial numbers:

images

These combinatorial numbers are the coefficients in the expansion of (a + b)n and are often called binomial coefficients. Moreover, the third entry of each row, that is, the numbers of the form images , are the sums of the positive integers from 1 to n − 1, as can be seen by using equation 1.2 in Chapter 1, after replacing n by n −1. These numbers are triangular.

The principle used to generate the (n + 1)st row from the nth row can be written as

(3.4)images

EXERCISES

An asterisk (*) indicates that the exercise can be developed into a research project.

  1. Write a program to find n! for a given nonnegative integer, n. Then use this program to tabulate n! for all n ≤ 20. You can use either of the factorial examples to help you do this.
  2. Using the previous exercise, write a program to find images for a given pair of integers k and n such that 0 ≤ k ≤ n/2, with n ≠ 0, using formula (3.2). (Why can we assume that k ≤ n/2?)
  3. Now, write a program to find images using formula 3.1. Which program is faster? Why?
  4. Write a program that prints out the first k rows of Pascal’s triangle for a given k. See the example at the end of the chapter. Perhaps you can improve the formatting.
  5. 10! = 6!7!. Are there more relations of the form c! = a!b! where 2 ≤ a ≤ b < c ≤ 30?
  6. *The 14th oblong number, 210, can be written as 5 × 6 × 7. Are there other oblong numbers less than 1000 that can be written as products of three consecutive numbers?
  7. *Find all triangular numbers less than 1000 that can be written as products of three or more consecutive integers.
  8. *Show that images for n ≤ 100.
  9. The Catalan numbers are defined by images and are useful in combinatorics, number theory, and computer science. They satisfy the recurrence relation images. Find the first 100 Catalan numbers (i) using this recurrence and (ii) using the definition. Which is faster?
  10. For n ≤ 1000, show that the entries of the nth row of Pascal’s triangle, excluding the initial and final 1’s, are all even if and only if n is a power of 2. The entries of the fourth row, for example, are 1, 4, 6, 4, 1, which, except for the initial and final 1’s, are even.
  11. For n ≤ 100, show that images.
  12. For n ≤ 100, show that images.
  13. *Verify that the following infinite array of equations involving the triangular numbers is correct for n ≤ 100.
    images
  14. Find 50 primes of the form 5n + 1.
  15. Given the polynomial f(n) = n2 + n + 41, verify that f(n) is prime for n = 0, 1, 2, …, 39.
  16. Show that n! is not a square when 1 < n < 50.
  17. *Consider the equation n!m! = s!t! where m > n and t > s. Write a program that accepts the values of n and m from the user and finds a pair s and t or determines that none exists. Verify that 4!15! = 7!13! yields an example of this equation.

Iterative Factorial

<!DOCTYPE HTML>
<html>
<meta charset="UTF-8">
<head>
<title>Factorial Iterative</title>
<script>
function fac(ns){
var n = parseInt(ns);
var start = new Date();
var startmm = start.getTime();
var ans = 1;
for (var j=1;j<(n+1);j++){
ans *= j;
}
var now = new Date();
nowmm = now.getTime();

var elapsed = nowmm - startmm;
alert("ans is "+ans+" performed in "+elapsed+" msec.");
return ans;
}

</script>
</head>
<body>
Choose limit <br/>
<form name="f" onsubmit="return fac(this.num.value);">
<input type="text" name="num" value="  "/>
<input type="submit" value="Submit a number "/>
</form>
<p id="place">
The answer will go here.
</p>
</body>
</html>

Recursive Factorial

<!DOCTYPE HTML>
<html>
<meta charset="UTF-8">
<head>
<title>Factorial Recursive</title>
<script>
function fac(ns){
var n = parseInt(ns);
var start = new Date();
var startmm = start.getTime();
var ans = worker(n);
var now = new Date();
nowmm = now.getTime();
var elapsed = nowmm - startmm;
alert("ans is "+ans+" performed in "+elapsed+" msec.");
return ans;
}
function worker(n){

if (n<=1) { return 1;}
else {return n*worker(n-1);}
}

</script>
</head>
<body>
Choose limit <br/>
<form name="f" onsubmit="return fac(this.num.value);">
<input type="text" name="num" value="  "/>
<input type="submit" value="Submit a number "/>
</form>
<p id="place">
The answer will go here.
</p>
</body>
</html>

Pascal’s Triangle

<title>Pascal's Triangle</title>
<script>

function triangle(ns){
var limit = parseInt(ns);
var output = "<center>";
output +="1<br/>";
var last = [1];
var lastext;
var next;
var val;
limit––;
while (limit>=0) {
//unshift and push each change the array itself. 
//Each returns new length
count = last.unshift(0);
last.push(0);
next = []; 
       
for (var i=0;i<count;i++){
val = last[i]+last[i+1];

next.push(val);
output+=String(val)+" ";
}
output+="<br/>";

last = next;
limit––;
}

output+="</center>";
document.getElementById("place").innerHTML = output;
return false;
}
</script>
</head>
<body>
Choose limit <br/>
<form name="f" onsubmit="return triangle(this.num.value);">
<input type="text" name="num" value="  "/>
<input type="submit" value="Submit a number "/>
</form>
<p id="place">
The answer will go here.
</p>
</body>
</html>
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset